@nlpjs/ner
Advanced tools
Comparing version 4.9.1 to 4.9.2
{ | ||
"name": "@nlpjs/ner", | ||
"version": "4.9.1", | ||
"version": "4.9.2", | ||
"description": "Named Entity Recognition", | ||
@@ -28,7 +28,7 @@ "author": { | ||
"dependencies": { | ||
"@nlpjs/core": "^4.6.0", | ||
"@nlpjs/core": "^4.9.2", | ||
"@nlpjs/language-min": "^4.6.0", | ||
"@nlpjs/similarity": "^4.9.1" | ||
}, | ||
"gitHead": "8133ce0c2da2d1c0c11ca787db27a4116215b875" | ||
"gitHead": "956809b1d31b96962f588bff97aef9b73794af4d" | ||
} |
@@ -52,27 +52,3 @@ /* | ||
registerDefault() { | ||
this.container.registerPipeline( | ||
'ner-process', | ||
[ | ||
'.decideRules', | ||
'extract-enum', | ||
'extract-regex', | ||
'extract-trim', | ||
'extract-builtin', | ||
], | ||
false | ||
); | ||
this.container.registerPipeline( | ||
'ner-??-process', | ||
[ | ||
'.decideRules', | ||
'extract-enum', | ||
'extract-regex', | ||
'extract-trim', | ||
'extract-builtin', | ||
'.reduceEdges', | ||
], | ||
false | ||
); | ||
} | ||
registerDefault() {} | ||
@@ -328,10 +304,36 @@ getRulesByName(locale = '*', name, force = false) { | ||
async defaultPipelineProcess(input) { | ||
if (!this.cache) { | ||
this.cache = { | ||
extractEnum: this.container.get('extract-enum'), | ||
extractRegex: this.container.get('extract-regex'), | ||
extractTrim: this.container.get('extract-trim'), | ||
extractBuiltin: this.container.get('extract-builtin'), | ||
}; | ||
} | ||
let output = await this.decideRules(input); | ||
output = await this.cache.extractEnum.run(output); | ||
output = await this.cache.extractRegex.run(output); | ||
output = await this.cache.extractTrim.run(output); | ||
output = await this.cache.extractBuiltin.run(output); | ||
output = await this.reduceEdges(output); | ||
return output; | ||
} | ||
async process(srcInput) { | ||
const input = { threshold: this.settings.threshold || 0.8, ...srcInput }; | ||
const result = await this.runPipeline( | ||
input, | ||
input.locale | ||
? `${this.settings.tag}-${input.locale}-process` | ||
: this.pipelineProcess | ||
); | ||
let result; | ||
if (input.locale) { | ||
const pipeline = this.container.getPipeline( | ||
`${this.settings.tag}-${input.locale}-process` | ||
); | ||
if (pipeline) { | ||
result = await this.runPipeline(input, pipeline); | ||
} | ||
} else if (this.pipelineProcess) { | ||
result = await this.runPipeline(input, this.pipelineProcess); | ||
} | ||
if (!result) { | ||
result = await this.defaultPipelineProcess(input); | ||
} | ||
delete result.threshold; | ||
@@ -338,0 +340,0 @@ return result; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45647
1335
Updated@nlpjs/core@^4.9.2