cts.entity( id as String, normalizedText as String, text as String, type as String ) as cts.entity
Returns a cts:entity
object. This is an opaque object you
can use to build an entity dictionary.
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>
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.