Constructor
new NlpManager(settings)
Constructor of the class.
Parameters:
Name | Type | Description |
---|---|---|
settings |
Object | Settings for the NLP Manager. |
- Source:
Methods
addAnswer(locale, intent, answer, condition)
Adds an answer for a locale and intent.
Parameters:
Name | Type | Description |
---|---|---|
locale |
String | Locale of the intent. |
intent |
String | Intent name. |
answer |
String | Text of the answer. |
condition |
String | Condition to be evaluated. |
- Source:
addDocument(srcLocale, utterance, intent)
Adds a new utterance associated to an intent for the given locale.
Parameters:
Name | Type | Description |
---|---|---|
srcLocale |
String | Locale of the language. |
utterance |
String | Text of the utterance. |
intent |
String | Intent name. |
- Source:
addLanguage(srcLocales)
Adds a language or several languages to the NLP Manager.
Parameters:
Name | Type | Description |
---|---|---|
srcLocales |
Array.<String> | Locales to be added. |
- Source:
addNamedEntityText(entityName, optionName, languages, texts)
Add new texts for an option of an entity for the given languages.
Parameters:
Name | Type | Description |
---|---|---|
entityName |
String | Name of the entity. |
optionName |
String | Name of the option. |
languages |
Array.<String> | Languages for adding the texts. |
texts |
Array.<String> | Texts to be added. |
- Source:
addRegexEntity(entityName, regex)
Adds a new regex named entity
Parameters:
Name | Type | Description |
---|---|---|
entityName |
String | Name of the entity. |
regex |
RegEx | Regular expression |
- Source:
addTrimEntity(entityName) → {Object}
Adds a new trim named entity.
Parameters:
Name | Type | Description |
---|---|---|
entityName |
String | Name of the entity. |
- Source:
Returns:
New Trim Named Entity instance.
- Type
- Object
assignDomain(intent, domain)
Assign an intent to a domain.
Parameters:
Name | Type | Description |
---|---|---|
intent |
String | Intent to be assigned. |
domain |
String | Domain to include the intent. |
- Source:
classify(srcLocale, srcUtterance)
Given an utterance and a locale, try to classify the utterance into one intent.
Parameters:
Name | Type | Description |
---|---|---|
srcLocale |
String | Locale of the text. If not provided, the locale is guessed. |
srcUtterance |
String | Text to be classified |
- Source:
clear()
Clear the NLP Manger.
- Source:
export(minified) → {String}
Export NLP manager information as a string.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
minified |
Boolean | false | If true, the returned JSON will have no spacing or indentation. |
- Source:
Returns:
NLP manager information as a JSON string.
- Type
- String
(async) extractEntities(srcLocale, srcUtterance, whitelist) → {Array.<Object>}
Process to extract entities from an utterance.
Parameters:
Name | Type | Description |
---|---|---|
srcLocale |
string | Locale of the utterance, optional. |
srcUtterance |
string | Text of the utterance. |
whitelist |
Array.<string> | Optional whitelist of entity names. |
- Source:
Returns:
Array of entities.
- Type
- Array.<Object>
getDomains()
Get an object with the intents of each domain.
- Source:
getIntentDomain(intent) → {String}
Returns the domain of a given intent.
Parameters:
Name | Type | Description |
---|---|---|
intent |
String | Intent name. |
- Source:
Returns:
Domain of the intent.
- Type
- String
getSentiment(srcLocale, srcUtterance)
Gets the sentiment of an utterance.
Parameters:
Name | Type | Description |
---|---|---|
srcLocale |
String | Locale of the text. If not provided, is guessed. |
srcUtterance |
Promise.String | Texto to analyze the sentiment. |
- Source:
guessLanguage(utterance) → {String}
Given a text, try to guess the language, over the languages used for the NLP.
Parameters:
Name | Type | Description |
---|---|---|
utterance |
String | Text to be guessed. |
- Source:
Returns:
ISO2 locale of the language, or undefined if not found.
- Type
- String
import(data)
Load NLP manager information from a string.
Parameters:
Name | Type | Description |
---|---|---|
data |
String | Object | JSON string or object to load NLP manager information from. |
- Source:
isEqualClassification(classifications) → {boolean}
Indicates if all the classifications has exactly 0.5 score.
Parameters:
Name | Type | Description |
---|---|---|
classifications |
Array.<Object> | Array of classifications. |
- Source:
Returns:
True if all classifications score is 0.5.
- Type
- boolean
load(srcFilename)
Load the NLP manager information from a file.
Parameters:
Name | Type | Description |
---|---|---|
srcFilename |
String | Filename for loading the NLP manager. |
- Source:
loadExcel(srcFileName)
Load the NLP manager information from an excel file.
Parameters:
Name | Type | Description |
---|---|---|
srcFileName |
Sting | File name of the excel. |
- Source:
(async) process(srcLocale, srcUtterance, Promise)
Process an utterance for full classify and analyze. If the locale is
not provided, then it will be guessed.
Classify the utterance and extract entities from it, returning an
object with all the information available.
Also calculates the sentiment of the utterance, if possible.
Parameters:
Name | Type | Description |
---|---|---|
srcLocale |
String | Language locale of the utterance. |
srcUtterance |
String | Text of the utterance. |
Promise |
Promise.Object | srcContext Context for finding answers. |
- Source:
removeAnswer(locale, intent, answer, condition)
Remove and answer from a locale and intent.
Parameters:
Name | Type | Description |
---|---|---|
locale |
String | Locale of the intent. |
intent |
String | Intent name. |
answer |
String | Text of the answer. |
condition |
String | Condition to be evaluated. |
- Source:
removeDocument(srcLocale, utterance, intent)
Removes an utterance associated to an intent for the given locale.
Parameters:
Name | Type | Description |
---|---|---|
srcLocale |
String | Locale of the language. |
utterance |
String | Text of the utterance. |
intent |
String | Intent name. |
- Source:
removeNamedEntityText(entityName, optionName, languages, texts)
Remove texts from an option of an entity for the given languages.
Parameters:
Name | Type | Description |
---|---|---|
entityName |
String | Name of the entity. |
optionName |
String | Name of the option. |
languages |
Array.<String> | Languages for adding the texts. |
texts |
Array.<String> | Texts tobe added. |
- Source:
save(srcFileName)
Save the NLP manager information into a file.
Parameters:
Name | Type | Description |
---|---|---|
srcFileName |
String | Filename for saving the NLP manager. |
- Source:
(async) train(locale)
Train the classifiers for the provided locales. If no locale is
provided, then retrain all the classifiers.
Parameters:
Name | Type | Description |
---|---|---|
locale |
Array.<String> | List of locales for being retrained. |
- Source: