Named Entities
Named entities are contained within named entity dictionaries.
Named entity dictionaries
Named entity dictionaries are required for processing large number of names, e.g. names of cities, countries, proper names, currencies, etc.
Dictionaries are contained within .csv files, with each line complying to the following format:
id; name; valueHere,
idis the unique identifier of the entity;nameis the entity name, possible synonyms are separated by commas;valueis the value of the entity, eitherstringorjson.
You may enumerate all the synonyms inside name and specify the main one as one of the json attributes.
Here is a fragment of a dictionary of proper names:
149;Bernard;{"name": "Bernard", "sex": "male"}
150;Bernie;{"name": "Bernie", "sex": "male"}
151;Berry;{"name": "Berry", "sex": "male"}
152;Bert, Bertram;{"name": "Bertram", "sex": "male"}
153;Bill,Billie,Billy;{"name": "Bill", "sex": "male"}
154;Blaine;{"name": "Blaine", "sex": "male"}Elements of named entity dictionaries
In order to access named entity dictionaries from named patterns, the following steps are necessary:
- Specify the dictionary name and its path in the
.scscript under therequiretag:
require: common/common-cities.csv
name = RoamingRegions
var = RoamingRegions- Define a converter in any
.jsfile. The converter allows to save pattern information into thevalueattribute of theparseTree. For example:
function RoamingRegionTagConverter($parseTree) {
var id = $parseTree.RoamingRegions[0].value;
return RoamingRegions[id].value
}Here,
RoamingRegionTagConverteris the name of the converter;RoamingRegionsis the name of the named entity dictionary.
The returned value is saved into the value attribute.
- Declare a named pattern. Use
$entity<>:
$roamingRegion = $entity<RoamingRegions> || converter = RoamingRegionTagConverterNamed entities can be used even without declaring a named pattern.
When a named pattern is assigned a converter, a $parseTree’s value attribute will then include the value of the corresponding dictionary element.