Loading TOC...

MarkLogic 12 EA 2 Product Documentation
cts:entity

cts:entity(
   $id as xs:string,
   $normalizedText as xs:string,
   $text as xs:string,
   $type as xs:string
) as cts:entity

Summary

Returns a cts:entity object. This is an opaque object that can be used 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. The variable $cts:entity-id in cts:entity-highlight and cts:entity-walk will be filled in with this ID for each matching entity.
normalizedText The normalized form of the entity. For entities created from a SKOS ontology this could be the preferred label of the Concept. The variable $cts:normalized-text in cts:entity-highlight and cts:entity-walk will be filled in with this form for each matching entity.
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. The variable $cts:entity-type in cts:entity-highlight and cts:entity-walk will be filled in with this type for each matching entity.

Example

let $dict := 
  cts:entity-dictionary(
    for $alt in ("ADA", "Obamacare", "Affordable Care Act")
    return cts:entity("E1", "ADA", $alt", "Law")
  )
return 
  cts:entity-highlight(<root>ADA is often called Obamacare</root>,
    element {$cts:entity-type} {attribute norm {$cts:normalized-text}, $cts:text}, $dict)
=>
<root><Law norm="ADA">ADA</Law> is often called <Law norm="ADA">Obamacare</Law>.</root>

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.