Appery Entity Extraction
CordovaMlPlugin
Entity Extraction
Extract entities from text
EntityExtractor.extractEntities
Parameters
- {string}
text
- text to extract entities from - {string}
modelIdentifier
- identifier of a model used for entity extraction - {function}
success
- callback function which takes a parameter data which will be invoked on success - {function}
error
- callback function which takes a parameter err which will be invoked on failure - {object}
options
- options for entity extraction
Important notice:
Model used for entity extraction should be downloaded before calling extractEntities
.
Check it with EntityExtractor.getDownloadedEntityExtractionModels
and then call EntityExtractor.downloadEntityExtractionModel
if desired model is missing (see below).
Supported model identifiers can be retrieved via EntityExtractor.getSupportedEntityExtractionModels
.
Supported options
Property | Description | Examples |
---|---|---|
referenceTime | Reference time based on which relative dates (e.g. “tomorrow”) should be interpreted. Represented as a number of milliseconds from the epoch of 1970-01-01T00:00:00 (UTC timezone) A null value means that the current time (when entity extraction is invoked) should be used. | 1619440306658 |
preferredLocale | A preferred locale that can be used to disambiguate potential values for date-time entities. Any of (or a subset of): en-* (en-US , en-UK , en-CA , ...), ar-* , de- , es- , fr-* , it- , ja- , ko-* , nl- , pl- , pt-* , ru- , th- , tr-* , zh-* . If not specified - the device’s system locale is used. | "en-UK" |
typesFilter | The subset of entity types that will be detected by the entity extractor. Types not present in the set will not be returned even if they are present in the input text. If not specified - all types of entities are detected. Check the list of supported entity types | ["address", "flight"] |
referenceTimeZone | Timezone string in tzdata compatible format. Reference time zone based on which relative dates (e.g. “tomorrow”) should be interpreted. If this is not set, the current time zone (when entity extraction is invoked) will be used. | "America/New_York" |
downloadModelIfNeeded | Boolean flag, it enables automatic downloading of an extraction model if it isn't yet downloaded | true |
Response format
For each found entity its location is specified with two fields:
location
- index of the first character of the entitylength
- number of characters in the entity
entities
field contain a list of entity descriptors. Each descriptor has a type
field which contains entity type code (look here for a list of possible values) and possibly other fields which are specific for an entity type.
Entity Types
Code | Description | Example | Additional fields in entity descriptor |
---|---|---|---|
address | Address | 350 third street, Cambridge MA | |
flight | Flight Number (IATA flight codes only) | LX37 |
|
iban | IBAN | CH52 0483 0000 0000 0000 9 |
|
datetime | Date-Time | 2019/09/29, let's meet tomorrow at 6pm |
|
isbn | ISBN (version 13 only) | 978-1101904190 |
|
phone | Phone Number | (555) 225-3556 | |
payment_card | Payment / Credit Cards | 4111 1111 1111 1111 |
|
email | Email address | [email protected] | |
tracking_number | Tracking Number (standardized international formats) | 1Z204E380338943508 |
|
money | Money/Currency (Arabic numerals only) | $12, 25 USD |
|
url | URL | https://en.wikipedia.org/wiki/Platypus |
Parcel carrier codes
Code | Value |
---|---|
fedEx | FedEX |
ups | UPS |
dhl | DHL |
usps | USPS |
ontrac | Ontrac |
lasership | Lasership |
israelPost | Israel Post |
swissPost | Swiss Post |
msc | MSC |
amazon | Amazon |
iParcel | IParcel |
unknown | Unknown carrier |
Payment card network codes
Code | Value |
---|---|
amex | Amex |
dinersClub | DinersClub |
discover | Discover |
interPayment | InterPayment |
jcb | JCB |
maestro | Maestro |
mastercard | Mastercard |
mir | Mir |
troy | Troy |
unionPay | Unionpay |
visa | Visa |
unknown | Unknown network |
Example
ApperyioMLCordovaPlugin.EntityExtractor.extractEntities(
"You can contact the test team tomorrow at [email protected] to determine the best timeline. To follow the progress of your delivery please use this tracking number: 9612804152073070474837",
"english",
results => console.log(results),
error => console.log(error),
{"preferredLocale": "en-UK"});
Sample JSON callback: entity_extraction.json
Get supported extraction models
EntityExtractor.getSupportedEntityExtractionModels
Parameters
- {function}
success
- callback function which takes a parameter data which will be invoked on success - {function}
error
- callback function which takes a parameter err which will be invoked on failure
Example
ApperyioMLCordovaPlugin.EntityExtractor.getSupportedEntityExtractionModels(
results => console.log(results),
error => console.log(error));
Sample JSON callback: supported_entity_extraction_models.json
Get downloaded entity extraction models
EntityExtractor.getDownloadedEntityExtractionModels
List of language models that have been downloaded to the device.
Parameters
- {function}
success
- callback function which takes a parameter data which will be invoked on success - {function}
error
- callback function which takes a parameter err which will be invoked on failure
Example
ApperyioMLCordovaPlugin.EntityExtractor.getSupportedEntityExtractionModels(
results=>console.log(results),
error => console.log(error));
Sample JSON callback: downloaded_entity_extraction_models.json
Download and delete entity extraction models
EntityExtractor.downloadEntityExtractionModel
EntityExtractor.deleteEntityExtractionModel
Download or delete an entity extraction model with specified model identifier.
Parameters
- {string}
modelIdentifier
- model identifier - {function}
success
- callback function which takes a parameter data which will be invoked on success - {function}
error
- callback function which takes a parameter err which will be invoked on failure
Example
ApperyioMLCordovaPlugin.EntityExtractor.downloadEntityExtractionModel("russian", successCallback, errorCallback)
ApperyioMLCordovaPlugin.EntityExtractor.deleteEntityExtractionModel("russian", successCallback, errorCallback)
Sample JSON callback: download_delete_entity_extraction_model.json
Updated 4 months ago