new Fuzzy()
A version of the Natural Language Processing core. Doesn't follow entity order but tries to guess names by samples. Less precise but easier hits.
- Source:
Methods
addDocument(text, intent) → {boolean}
Add a new document.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
text |
string | The document content. | ||
intent |
string | The related intent. | ||
guess.fromFullSentence |
boolean |
<optional> |
false | Indicates that the document is a full untagged sentence. (i.e. "Please call the 333-123456") |
guess.fromTaggedSentence |
boolean |
<optional> |
true | Indicates that the document is tagged with braces. (i.e "Please call the {phone_number}") |
guess.expandIntent |
boolean |
<optional> |
false | Extends or creates a new intent if exceeded entities are found. New entities id will be autogenerated and progressive. |
guess.withNames |
Array.<string> |
<optional> |
[] | Uses the given names for auto-extending intents. Positions in array are matched with positions of entity into the specified sentence. |
- Source:
Returns:
True when found.
- Type
- boolean
addEntity(entity) → {boolean}
Adds an entity recognizer.
Parameters:
Name | Type | Description |
---|---|---|
entity |
EntityRecognizer | The entity recognizer to be addded. |
- Source:
Returns:
True when successful.
- Type
- boolean
addIntent(intentName, entities) → {boolean}
Adds an intent.
Parameters:
Name | Type | Description |
---|---|---|
intentName |
string | The name of the new intent. |
entities |
Array.<IntentEntity> | The produced entities. |
- Source:
Returns:
True when successful.
- Type
- boolean
getConfidence() → {number}
Returns the confidence ratio.
- Source:
Returns:
The confidence ratio.
- Type
- number
hasEntity(entityName) → {boolean}
Check if an entity with a given name exists.
Parameters:
Name | Type | Description |
---|---|---|
entityName |
string | The entity name. |
- Source:
Returns:
True when found.
- Type
- boolean
setConfidence(ratio)
Set confidence ratio, from 0.5 to 1. The higher the more strict.
Parameters:
Name | Type | Description |
---|---|---|
ratio |
number | The confidence ratio to be set. |
- Source:
test(text, methodopt) → {NlpResult|false}
Check if a given sentence matches an intent and extracts its entities.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
text |
string | The sentence to be processed. | ||
method |
string |
<optional> |
"default" | The extraction method. "anyEntity" extracts all found entities and guess intent, regardless the intents structure. |
- Source:
Returns:
-
When an intent is found.
- Type
- NlpResult
-
When the sentence doesn't match any intent.
- Type
- false