edu.uchsc.ccp.iaa
Class Annotation

java.lang.Object
  extended by edu.uchsc.ccp.iaa.Annotation

public class Annotation
extends Object


Field Summary
static int IGNORE_SPANS_COMPARISON
           
static int SPANS_EXACT_COMPARISON
           
static int SPANS_OVERLAP_COMPARISON
           
 
Constructor Summary
Annotation()
           
 
Method Summary
static boolean classesMatch(Annotation annotation1, Annotation annotation2)
          returns true only if both annotations have the same non-null annotationClass.
static int compareAnnotations(Annotation annotation1, Annotation annotation2, int spanComparison, boolean compareClass, Set<String> simpleFeatureNames)
          This method compares two annotations with respect to their spans, annotation classes and simple features.
static int compareComplexFeature(Annotation annotation1, Annotation annotation2, String complexFeatureName, int complexFeatureSpanComparison, boolean complexFeatureClassComparison, Set<String> simpleFeatureNamesOfComplexFeature, boolean trivialSimpleFeatureMatchesCauseTrivialMatch)
          This method compares the complex features of two annotations.
static boolean compareComplexFeatureNames(Annotation annotation1, Annotation annotation2)
          This method checks to see if two annotations have the same complex features but does not compare the values of the features.
static boolean compareFeatureNames(Annotation annotation1, Annotation annotation2)
           
static int compareSimpleFeature(Annotation annotation1, Annotation annotation2, String featureName)
           
static boolean compareSimpleFeatureNames(Annotation annotation1, Annotation annotation2)
          This method checks to see if two annotations have the same simple features but does not compare the values of the features.
static int compareSimpleFeatures(Annotation annotation1, Annotation annotation2)
          Compares all of the simple features of two annotations
static int compareSimpleFeatures(Annotation annotation1, Annotation annotation2, Set<String> featureNames)
          Compares the simple features of two annotations named in featureNames
 String getAnnotationClass()
           
 Set<String> getComplexFeatureNames()
           
 Set<Annotation> getComplexFeatureValues(String featureName)
           
static String getCoveredText(Annotation annotation, String annotationText, String spanSeparator)
          Returns the text covered by an annotation.
 String getDocID()
           
 Set<String> getFeatureNames()
           
 String getSetName()
           
static Annotation getShortestAnnotation(Collection<Annotation> annotations)
          This method returns the shortest annotation - that is the annotation whose span is the shortest.
 Set<String> getSimpleFeatureNames()
           
 Set<Object> getSimpleFeatureValues(String featureName)
           
 int getSize()
           
 List<Span> getSpans()
           
 boolean isComplexFeature(String featureName)
           
 boolean isSimpleFeature(String featureName)
           
 void setAnnotationClass(String type)
           
 void setComplexFeature(String featureName, Annotation featureValue)
           
 void setComplexFeature(String featureName, Set<Annotation> featureValues)
           
 void setDocID(String docID)
           
 void setSetName(String setName)
           
 void setSimpleFeature(String featureName, Object featureValue)
           
 void setSimpleFeature(String featureName, Set<Object> featureValues)
           
 void setSpan(Span span)
           
 void setSpans(List<Span> spans)
           
static boolean spansMatch(Annotation annotation1, Annotation annotation2)
           
static boolean spansMatch(List<Annotation> annotations)
           
static boolean spansOverlap(Annotation annotation1, Annotation annotation2)
           
 String toHTML()
          this needs to be moved out of this class
 String toHTML(boolean printComplexFeatures)
           
static int trivialCompare(Set values1, Set values2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SPANS_OVERLAP_COMPARISON

public static final int SPANS_OVERLAP_COMPARISON
See Also:
Constant Field Values

SPANS_EXACT_COMPARISON

public static final int SPANS_EXACT_COMPARISON
See Also:
Constant Field Values

IGNORE_SPANS_COMPARISON

public static final int IGNORE_SPANS_COMPARISON
See Also:
Constant Field Values
Constructor Detail

Annotation

public Annotation()
Method Detail

getSetName

public String getSetName()

setSetName

public void setSetName(String setName)

getDocID

public String getDocID()

setDocID

public void setDocID(String docID)

getAnnotationClass

public String getAnnotationClass()

setAnnotationClass

public void setAnnotationClass(String type)

getSpans

public List<Span> getSpans()

setSpans

public void setSpans(List<Span> spans)

setSpan

public void setSpan(Span span)

getSimpleFeatureNames

public Set<String> getSimpleFeatureNames()

getSimpleFeatureValues

public Set<Object> getSimpleFeatureValues(String featureName)

isSimpleFeature

public boolean isSimpleFeature(String featureName)

setSimpleFeature

public void setSimpleFeature(String featureName,
                             Set<Object> featureValues)

setSimpleFeature

public void setSimpleFeature(String featureName,
                             Object featureValue)

getComplexFeatureNames

public Set<String> getComplexFeatureNames()

getComplexFeatureValues

public Set<Annotation> getComplexFeatureValues(String featureName)

isComplexFeature

public boolean isComplexFeature(String featureName)

setComplexFeature

public void setComplexFeature(String featureName,
                              Set<Annotation> featureValues)

setComplexFeature

public void setComplexFeature(String featureName,
                              Annotation featureValue)

getFeatureNames

public Set<String> getFeatureNames()

spansMatch

public static boolean spansMatch(Annotation annotation1,
                                 Annotation annotation2)
Parameters:
annotation1 -
annotation2 -
Returns:
true if the annotations have the same spans

spansMatch

public static boolean spansMatch(List<Annotation> annotations)

classesMatch

public static boolean classesMatch(Annotation annotation1,
                                   Annotation annotation2)
returns true only if both annotations have the same non-null annotationClass.


spansOverlap

public static boolean spansOverlap(Annotation annotation1,
                                   Annotation annotation2)

compareSimpleFeatureNames

public static boolean compareSimpleFeatureNames(Annotation annotation1,
                                                Annotation annotation2)
This method checks to see if two annotations have the same simple features but does not compare the values of the features.

Parameters:
annotation1 -
annotation2 -
Returns:
true if both annotations have the same number of simple features and they have the same names.

compareComplexFeatureNames

public static boolean compareComplexFeatureNames(Annotation annotation1,
                                                 Annotation annotation2)
This method checks to see if two annotations have the same complex features but does not compare the values of the features.

Parameters:
annotation1 -
annotation2 -
Returns:
true if both annotations have the same number of complex features and they have the same names.

compareFeatureNames

public static boolean compareFeatureNames(Annotation annotation1,
                                          Annotation annotation2)

trivialCompare

public static int trivialCompare(Set values1,
                                 Set values2)
Parameters:
values1 - the value of a feature (simple or complex)
values2 - the value of another feature (simple or complex)
Returns:
MatchResult.TRIVIAL_MATCH if both values are null, one is null and the other empty, or if both are empty
MatchResult.TRIVIAL_NONMATCH if one of the values is empty and they other is not, or if one values is null and the other is not null and not empty
MatchResult.NONTRIVIAL_NONMATCH if the sizes of the values are different.
MatchResult.MATCH_RESULT_UNASSIGNED is none of the above.
See Also:
MatchResult

compareSimpleFeature

public static int compareSimpleFeature(Annotation annotation1,
                                       Annotation annotation2,
                                       String featureName)
Parameters:
annotation1 -
annotation2 -
featureName - the name of the feature that will be compared between the two annotations
Returns:
MatchResult.TRIVIAL_NONMATCH if the featureName does not correspond to a simple feature in either or both of the annotations
the result of trivialCompare for the feature values unless that method returns MatchResult.MATCH_RESULT_UNASSIGNED. Otherwise,
MatchResult.NONTRIVIAL_MATCH if the values of the features are equal as defined by the equals method.
MatchResult.NONTRIVIAL_NONMATCH if the values are not equal as defined by the equals method.
See Also:
trivialCompare(Set, Set)

compareSimpleFeatures

public static int compareSimpleFeatures(Annotation annotation1,
                                        Annotation annotation2)
Compares all of the simple features of two annotations

Parameters:
annotation1 -
annotation2 -
Returns:
  • TRIVIAL_NONMATCH if any of the simple features are trivial non-matches.
  • NONTRIVIAL_NONMATCH there is a non-matching simple feature and all non-matching simple features are non-trivial.
  • TRIVIAL_MATCH all simple features match and there is one simple feature that is a trivial match.
  • TRIVIAL_MATCH if there are no simple features.
  • NONTRIVIAL_MATH all simple features match and are non-trivial
See Also:
MatchResult.NONTRIVIAL_MATCH, MatchResult.NONTRIVIAL_NONMATCH, MatchResult.TRIVIAL_MATCH, MatchResult.TRIVIAL_NONMATCH

compareSimpleFeatures

public static int compareSimpleFeatures(Annotation annotation1,
                                        Annotation annotation2,
                                        Set<String> featureNames)
Compares the simple features of two annotations named in featureNames

Parameters:
annotation1 -
annotation2 -
featureNames - the simple features to compare.
Returns:
  • TRIVIAL_NONMATCH if any of the features are trivial non-matches
  • NONTRIVIAL_NONMATCH if each of the simple features that are non-matching are also non-trivial. For example, if there are five simple features being compared and 2 are trivial matches, 1 is a non-trivial match, and the other 2 are non-trivial non-matches, then NONTRIVIAL_NONMATCH will be returned.
  • TRIVIAL_MATCH if all of the features match and at least one of them is a trivial match
  • TRIVIAL_MATCH if featureNames is an empty set or null.
  • NONTRIVIAL_MATH all simple features match and are non-trivial
See Also:
compareSimpleFeature(Annotation, Annotation, String), MatchResult.NONTRIVIAL_MATCH, MatchResult.NONTRIVIAL_NONMATCH, MatchResult.TRIVIAL_MATCH, MatchResult.TRIVIAL_NONMATCH

compareComplexFeature

public static int compareComplexFeature(Annotation annotation1,
                                        Annotation annotation2,
                                        String complexFeatureName,
                                        int complexFeatureSpanComparison,
                                        boolean complexFeatureClassComparison,
                                        Set<String> simpleFeatureNamesOfComplexFeature,
                                        boolean trivialSimpleFeatureMatchesCauseTrivialMatch)
This method compares the complex features of two annotations. A complex feature has a name and a value. The value is a set of Annotations (typically one - but can be more). The parameters to this method determine how the feature values should be compared.

Parameters:
annotation1 -
annotation2 -
complexFeatureName - the name of the feature that will be compared between the two annotations
complexFeatureSpanComparison - specifies how the spans of the feature values should be compared. The value of this parameter must be one of SPANS_OVERLAP_COMPARISON, SPANS_EXACT_COMPARISON, or IGNORE_SPANS_COMPARISON. If IGNORE_SPANS_COMPARISON is passed in, then the spans will be considered as matching.
complexFeatureClassComparison - specifies how the classes of the feature values should be compared. If true, then the classes will be compared and will be considered matched if they are the same. If false, then the classes will not be compared and will be considered as matching.
simpleFeatureNamesOfComplexFeature - specifies which simple features of the feature values should be compared. If null or an empty set is passed in, then the next parameter should probably be set to 'false'.
trivialSimpleFeatureMatchesCauseTrivialMatch - this parameter determines how a TRIVIAL_MATCH between simple features of the feature values should affect the return value of this method. If true, then a trivial match between any of the simple features of the feature values will cause TRIVIAL_MATCH (if it not a non-match) to be returned. If false, then a trivial match between any of the simple features will not have an effect on whether the return value of this method is TRIVIAL or NONTRIVIAL.
Returns:
MatchResult.TRIVIAL_NONMATCH if the featureName does not correspond to a complex feature in either or both of the annotations
the result of trivialCompare(Set, Set) for the feature values unless that method returns MatchResult.MATCH_RESULT_UNASSIGNED. Note that this is the only other criteria under which TRIVIAL_NONMATCH is returned.
MatchResult.NONTRIVIAL_MATCH if the values of the complex feature match as defined by the match parameters.
MatchResult.TRIVIAL_MATCH if the values of the complex feature match trivially and the parameter trivialSimpleFeatureMatchesCauseTrivialMatch is true.
MatchResult.NONTRIVIAL_NONMATCH if the values are not equal as defined by the match parameters.

compareAnnotations

public static int compareAnnotations(Annotation annotation1,
                                     Annotation annotation2,
                                     int spanComparison,
                                     boolean compareClass,
                                     Set<String> simpleFeatureNames)
This method compares two annotations with respect to their spans, annotation classes and simple features.

Parameters:
annotation1 -
annotation2 -
spanComparison - must be one of SPANS_OVERLAP_COMPARISON, SPANS_EXACT_COMPARISON, or IGNORE_SPANS_COMPARISON. If IGNORE_SPANS_COMPARISON is passed in, then the spans will be considered as matching.
compareClass - if true, then the classes will be compared and will be considered matched if they are the same. If false, then the classes will not be compared and will be considered as matching.
simpleFeatureNames - the simple features that will be compared.
Returns:
MatchResult.TRIVIAL_NONMATCH if the spans do not match. MatchResult.TRIVIAL_NONMATCH if the classes do not match. MatchResult.TRIVIAL_MATCH if spans and classes match and simpleFeatureNames is empty or null. If spans and classes match, then the result of compareSimpleFeatures(Annotation, Annotation, Set) is returned.
See Also:
compareSimpleFeatures(Annotation, Annotation, Set)

getCoveredText

public static String getCoveredText(Annotation annotation,
                                    String annotationText,
                                    String spanSeparator)
Returns the text covered by an annotation.

Parameters:
annotation - an annotation that has spans corresponding to extents of annotationText
annotationText - the text from which an annotation corresponds to.
spanSeparator - if more than one span exists, then this String will be inserted between each segment of text.
Returns:
the text covered by an annotation.

getSize

public int getSize()
Returns:
the size of the span associated with the annotation. If the annotation has more than one span, then the sum of the size of the spans is returned.

getShortestAnnotation

public static Annotation getShortestAnnotation(Collection<Annotation> annotations)
This method returns the shortest annotation - that is the annotation whose span is the shortest. If an annotation has more than one span, then its size is the sum of the size of each of its spans.

Parameters:
annotations -
Returns:
will only return one annotation. In the case of a tie, will return the first annotation with the smallest size encountered during iteration. Returns null if annotations is null or empty.

toHTML

public String toHTML()
this needs to be moved out of this class

Returns:
an html representation of the annotation

toHTML

public String toHTML(boolean printComplexFeatures)