cts.entityDictionary( entities as cts.entity[], [options as String[]] ) as cts.entityDictionary
Returns a cts:entity-dictionary
object.
Use this function when creating ad hoc entity dictionaries, or as a prelude to saving an entity dictionary to the database.
const entries = []; for (let alt of ['ACA', 'Obamacare', 'Affordable Care Act']) { entries.push(cts.entity('E1', 'ACA', alt, 'Law')); } const dictionary = cts.entityDictionary(entries); const inputNode = new NodeBuilder() .addElement('node', 'ACA is often called Obamacare') .toNode(); const resultBuilder = new NodeBuilder(); cts.entityHighlight(inputNode, function(builder, entityType, text, normText, entityId, node, start) { builder.startElement(entityType) .addAttribute('norm', normText) .addText(text) .endElement(); }, resultBuilder, dictionary); resultBuilder.toNode(); // Returns the following output: // // <node><Law norm="ACA">ACA</Law> is often called <Law norm="ACA">Obamacare</Law></node>