diff options
| author | Sam Wilkins <samwilkins333@gmail.com> | 2019-07-23 03:13:08 -0400 |
|---|---|---|
| committer | Sam Wilkins <samwilkins333@gmail.com> | 2019-07-23 03:13:08 -0400 |
| commit | 767901272eeea30137330e710cc8cf70fd34f1de (patch) | |
| tree | 88911c9dc2370038fdd5c0c15cf83629565f77c2 /src/client/cognitive_services/CognitiveServices.ts | |
| parent | 010c7978ce19392b4f02bdea29e734ac2abac01f (diff) | |
autotag based on confidence, allow concealment of computed fields that resolve to undefined with namespace constant ComputedField.undefined
Diffstat (limited to 'src/client/cognitive_services/CognitiveServices.ts')
| -rw-r--r-- | src/client/cognitive_services/CognitiveServices.ts | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/client/cognitive_services/CognitiveServices.ts b/src/client/cognitive_services/CognitiveServices.ts index d525455cb..04a21c837 100644 --- a/src/client/cognitive_services/CognitiveServices.ts +++ b/src/client/cognitive_services/CognitiveServices.ts @@ -6,6 +6,8 @@ import { List } from "../../new_fields/List"; import { Docs } from "../documents/Documents"; import { RouteStore } from "../../server/RouteStore"; import { Utils } from "../../Utils"; +import { CompileScript } from "../util/Scripting"; +import { ComputedField } from "../../new_fields/ScriptField"; export enum Services { ComputerVision = "vision", @@ -107,12 +109,13 @@ export namespace CognitiveServices { let converter = (results: any) => { let tagDoc = new Doc; results.tags.map((tag: Tag) => { - if (tag.confidence >= +threshold) { - tagDoc[tag.name] = tag.confidence; - } + let sanitized = tag.name.replace(" ", "_"); + let script = `return (${tag.confidence} >= this.confidence) ? ${tag.confidence} : ${ComputedField.undefined}`; + let computed = CompileScript(script, { params: { this: "Doc" } }); + computed.compiled && (tagDoc[sanitized] = new ComputedField(computed)); }); tagDoc.title = "Generated Tags"; - tagDoc.confidenceThreshold = threshold.toString(); + tagDoc.confidence = threshold; return tagDoc; }; analyzeDocument(target, Services.ComputerVision, converter, "generatedTags"); |
