Loading TOC...

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 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. 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.

See Also

Example

xquery version "1.0-ml";

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

(: Returns output such as the following:
 :
 : <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.