Loading TOC...

MarkLogic 9 Product Documentation
cts.entityDictionary

cts.entityDictionary(
   entities as cts.entity[],
   [options as String[]]
) as cts.entityDictionary

Summary

Returns a cts:entity-dictionary object.

Parameters
entities The entities to put into the dictionary.
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.
  • "case-sensitive" or "case-insensitive": Perform case-sensitive or case-insensitive matching of entities names. Specify one or the other. Default: "case-sensitive".
  • "remove-overlaps" or "allow-overlaps": Either eliminate entities with the overlapping names or allow them. Specify one or the other. Default: "allow-overlaps".
  • "whole-words" or "partial-words": Either require matches to align with token boundares, or allow matches to fall within token boundaries. Specify one or the other. Default: "whole-words".

Usage Notes

Use this function when creating ad hoc entity dictionaries, or as a prelude to saving an entity dictionary to the database.

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.