Constructor
new NerManager(settings)
Constructor of the class.
Parameters:
Name | Type | Description |
---|---|---|
settings |
Object | Settings for initializing this instance. |
- Source:
Methods
addNamedEntity(entityName, type) → {Object}
Adds a new entity to be managed by the NER. If the entity already exists,
then returns the already existing one.
Parameters:
Name | Type | Description |
---|---|---|
entityName |
String | Name of the entity. |
type |
String | Type of the entity. |
- Source:
Returns:
Already existing entity or the new one created.
- Type
- Object
addNamedEntityText(entityName, optionName, srcLanguages, srcTexts)
Add texts to the given languages of an option of an entity.
Parameters:
Name | Type | Description |
---|---|---|
entityName |
String | Name of the entity. |
optionName |
String | Name of the option. |
srcLanguages |
Array.<String> | Language or languages for adding the texts. |
srcTexts |
Array.<String> | Text or texts to be added. |
- Source:
calculateResolution(entity, locale) → {Object}
Given an entity and a locale, calculate the resolution.
Parameters:
Name | Type | Description |
---|---|---|
entity |
Object | Entity instance with resolution. |
locale |
string | Entity language locale. |
- Source:
Returns:
Calculated resolution for the entity.
- Type
- Object
findBuiltinEntities(utterance, language) → {Array.<Object>}
Extract built-in entities for the utterance given the language.
Parameters:
Name | Type | Description |
---|---|---|
utterance |
string | Input utterance. |
language |
string | Language locale. |
- Source:
Returns:
Extracted entities as edges array.
- Type
- Array.<Object>
(async) findEntities(utterance, locale, whitelist) → {Array.<Promise.Object>}
Find entities inside an utterance.
Parameters:
Name | Type | Description |
---|---|---|
utterance |
String | Utterance for searching entities. |
locale |
String | Locale of the language. |
whitelist |
Array.<String> | Whitelist of entity names. |
- Source:
Returns:
Promise edges of entities found.
- Type
- Array.<Promise.Object>
(async) generateEntityUtterance(utterance, locale) → {Promise.String}
Find entities on utterance, and replace them by the entity name.
Parameters:
Name | Type | Description |
---|---|---|
utterance |
String | Utterance to be processed. |
locale |
String | Locale of the utterance. |
- Source:
Returns:
Promise utterance with entities replaced by entity name.
- Type
- Promise.String
getEntitiesFromUtterance(utterance) → {Array.<String>}
Given an utterance, search for %entity% format inside it, in order to
return the list of entities referenced by the utterance.
Parameters:
Name | Type | Description |
---|---|---|
utterance |
String | Utterance for searching. |
- Source:
Returns:
List of entities.
- Type
- Array.<String>
getNamedEntity(entityName, force) → {Object}
Get an entity given its name. If the entity does not exists and the
force flag is on, then creates the entity.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
entityName |
String | Name of the entity. | |
force |
boolean | false | Flag to create the entity when it does not exists. |
- Source:
Returns:
The entity, or undefined if not found and not forced.
- Type
- Object
inverseTranslate(str, locale) → {string}
Given a resolution unit in default language, translate into source language.
Parameters:
Name | Type | Description |
---|---|---|
str |
string | Resolution unit in default language. |
locale |
string | Source language locale. |
- Source:
Returns:
Translation or default resolution unit.
- Type
- string
load(obj)
Load this instance from an object.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | Object to load from. |
- Source:
newNamedEntity(entityName, type) → {NamedEntity}
Creates a new instance of a named entity.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
entityName |
string | Name of the entity | |
type |
string | enum | Type of the entity |
- Source:
Returns:
New named entity.
- Type
- NamedEntity
prereduceEdges(edges) → {Array.<Object>}
Execute a pre-reduction of edges before running the final reduce edges.
Parameters:
Name | Type | Description |
---|---|---|
edges |
Array.<Object> | Array of edges. |
- Source:
Returns:
Array of reduced edges.
- Type
- Array.<Object>
removeNamedEntity(entityName)
Removes an entity from the NER.
Parameters:
Name | Type | Description |
---|---|---|
entityName |
String | Name of the entity. |
- Source:
removeNamedEntityText(entityName, optionName, srcLanguages, srcTexts)
Remove texts for the given languages of the option of an entity.
Parameters:
Name | Type | Description |
---|---|---|
entityName |
String | Name of the entity. |
optionName |
String | Name of the option. |
srcLanguages |
Array.<String> | Languages affected. |
srcTexts |
Array.<String> | Texts to be removed. |
- Source:
save() → {Object}
Returns a clone object representing this, for saving.
- Source:
Returns:
Clone object.
- Type
- Object
splitEdges(edges) → {Array.<Object>}
Given an array of edges, detect the trim edges and find overlaps with
non trim edges. When an overlap is detected, reduce the trim edged to
fit with the other edge.
Parameters:
Name | Type | Description |
---|---|---|
edges |
Array.<Object> | Edges to be splited |
- Source:
Returns:
Splited edges.
- Type
- Array.<Object>
translate(str, locale) → {string}
Given a resolution unit in source language, translate into default language.
Parameters:
Name | Type | Description |
---|---|---|
str |
string | Resolution unit in source language. |
locale |
string | Source language locale. |
- Source:
Returns:
Translation or source resolution unit.
- Type
- string