Loading TOC...

cts.entity

cts.entity(
   $id as String,
   $normalizedText as String,
   $text as String,
   $type as String
) as cts.entity

Summary

Returns a cts:entity object. This is an opaque object you can use to build an entity dictionary.

Parameters
$id A unique ID for the entity. A unique entity may have multiple entries in the dictionary with different matching words: the unique ID ties them all together. For entities created from a SKOS ontology this could be the URI of the Concept.
$normalizedText The normalized form of the entity. For entities created from a SKOS ontology this could be the preferred label of the Concept.
$text The word (or phrase) to match during entity extraction. This will be an exact match, unless the dictionary was created with the "case-insensitive" option, in which case the string is matched with case folding. For entities created from a SKOS ontology this could be a label or alternative label for the Concept.
$type The type of the entity. For entities created from a SKOS ontology this could be the id of the top concept for the matching Concept, or its preferred label.

See Also

Example

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 iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.