cts.entityDictionaryParse( contents as String[], [options as String[]] ) as cts.entityDictionary
Construct a cts:entity-dictionary
object by parsing it from a formatted string.
Parameters | |
---|---|
contents | The dictionary entries to parse. Each line (or string) must consist of four tab-delimited fields: The entity ID, the normalized form of the entity, the word or phrase to match during entity identification, and the entity type. For more details about the fields, see cts.entity. Multiple formatted strings can be passed in and they will be combined into a single dictionary object. |
options |
Options with which you can control the behavior of the entity dictionary.
You can specify the following options. It is strongly recommended that
you use the default option settings.
|
'use strict'; const entity = require('/MarkLogic/entity'); // NOTE: The fields in the array items below must be TAB separated. const dictionary = cts.entityDictionaryParse([ '11208172 Nixon Nixon person:head of state', '11208172 Nixon Richard Nixon person:head of state', '11208172 Nixon Richard M. Nixon person:head of state', '11208172 Nixon Richard Milhous Nixon person:head of state', '11208172 Nixon President Nixon person:head of state', '08932568 Paris Paris administrative district:national capital', '09145751 Paris Paris administrative district:town', '09500217 Paris Paris imaginary being:mythical being' ]); const node = new NodeBuilder() .addElement('node', 'Nixon visited Paris') .toNode(); entity.enrich(node, dictionary); // Returns output similar to the following. (Whitespace added to improve // readability.) // // <node xmlns:e="http://marklogic.com/entity"> // <e:entity type="person:head of state">Nixon</e:entity> // visited // <e:entity type="administrative district:national capital">Paris</e:entity> // </node>
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.