Manage Annotations with the Annotation Manager
The Annotation Manager allows you to perform several operations on annotations under the right conditions. You can use it to copy, select, and remove annotations.
The Annotation Manager configuration consists of a list of operations.
Important: There is no define order of the execution of operations. If you really care about operation ordering, you must add several annotation managers to the semantic pipe. |
Copy Annotation
You can copy a source annotation along with its display form, display kind, and trust level to a target annotation.
Option |
Example |
---|---|
Copy without condition |
For example, to ignore the distinction between famous and nonfamous people. <Copy annotation="NE.famousperson" target="NE.person"/>
|
Copy with a condition |
For example, to copy famous people to the nonfamous people annotation, unless they are block listed. <Copy annotation="NE.famouspeople" target="NE.people"
unless="blocklisted"/>
|
Remove Annotation
You can remove the occurrences of an annotation under the right conditions.
Option |
Example |
---|---|
Remove without condition |
For example, to remove all end-of-sentences: <Remove annotation="sbreak" />
|
Remove an annotation if it overlaps with another one |
For example, to remove a person's name annotation when it spreads over two sentences: <Remove annotation="NE.person" ifOverlapWith="sbreak" />
|
Remove an annotation if the annotated text span matches that of another one |
For example, to remove a person's name annotation when the text is block listed: <Remove annotation="NE.person" ifMatchWith="blocklist.person”
/>
An ontology matcher upstream or any other semantic processor can set the
annotation |
Remove an annotation if the annotated text span and display form match those of another one |
For example, we want to implement a block list with a fine granularity: <Remove annotation="title.approx" ifMatchWith="blocklist.title"
displayFormsMustMatch="true"/>
If an ontology containing a <pkg path="title"> <Entry> <Form value="professor" />
</Entry> </pkg>
... the annotation is removed if the annotation ( |
Keep the first occurrence of an annotation and remove all others |
For example, to keep only the first organization occurrence in title and text: <KeepFirst annotation="NE.organization"
contexts="title,text"/>
|
Keep the longest leftmost of a set of overlapping annotations and remove all others |
<KeepLongestLeftMost annotations="NE.person,NE.place,NE.organization"
interTags="false"/>
With |
Select Annotation
You can select the most frequent annotations and store the results as document annotations.
Option |
Example |
---|---|
Select the most frequent values in a document for a given annotation |
For example, we want to select the 5 places that occur the most in a document
and store them in <SelectMostFrequentValue annotation="NE.place"
documentAnnotation="selectedPlace" howMany="5" truncate="true"/>
If there are more than 5 most frequent places, the resulting list is
arbitrarily truncated since |
Select the most frequent annotation in a document among a list |
<SelectMostFrequentAnnotation
annotations="NE.organization,NE.place,NE.person"
documentAnnotation="selectedAnnotation"/>
The most frequent annotation is used to output a
|
Select annotations depending on an index field (context) priority |
For example, we want to select an annotation from the <SelectByContexts annotation="NE.person" contexts="title,text"
documentAnnotation="selectedAnnotation" firstOnly="false"/>
With |
Use Regular Expressions
You can use regular expressions for all annotation parameters.
Set enableRegexp
to true
in the
<AnnotationManager>
object (default is false
).
Example of Annotation Manager XML Configuration File
<AnnotationManager xmlns="exa:com.exalead.linguistic.v10"> <Copy annotation="NE.famousperson" target="NE.person"/> <Copy annotation="NE.famousperson" target="NE.person" unless="blocklist"/> <Remove annotation="NE.famousperson" ifOverlapWith="sbreak" /> <Remove annotation="NE.person" ifOverlapWith="sbreak" /> <Remove annotation="NE.person" ifMatchWith="blocklist.person" /> <Remove annotation="title.approx" ifMatchWith="blocklist.title" displayFormsMustMatch="true"/> </AnnotationManager>