public class AnnotationDiffer extends Object
CORRECT_VALUE
(2), PARTIALLY_CORRECT_VALUE
(1) or
WRONG_VALUE
(0)depending on whether the two annotations match are
overlapping or completely unmatched. Each pairing also has a type of
CORRECT_TYPE
, PARTIALLY_CORRECT_TYPE
,
SPURIOUS_TYPE
or MISSING_TYPE
further detailing the type of
error for the wrong matches (missing being the keys that weren't
matched to a response while spurious are the responses that were
over-generated and are not matching any key.
Precision, recall and f-measure are also calculated.Modifier and Type | Class and Description |
---|---|
static interface |
AnnotationDiffer.Pairing
Interface representing a pairing between a key annotation and a response
one.
|
class |
AnnotationDiffer.PairingImpl
Represents a pairing of a key annotation with a response annotation and
the associated score for that pairing.
|
static class |
AnnotationDiffer.PairingOffsetComparator
Compares two choices based on start offset of key (or response
if key not present) and type if offsets are equal.
|
protected static class |
AnnotationDiffer.PairingScoreComparator
Compares two pairings:
the better score is preferred;
for the same score the better type is preferred (exact matches are
preffered to partial ones).
|
Modifier and Type | Field and Description |
---|---|
static int |
CORRECT_TYPE
Type for correct pairings (when the key and response match completely)
|
Set<Annotation> |
correctAnnotations |
protected int |
correctMatches
The number of correct matches.
|
protected List<AnnotationDiffer.Pairing> |
finalChoices
A list with the choices selected for the best result.
|
protected List<List<AnnotationDiffer.Pairing>> |
keyChoices
A list of lists representing all possible choices for each key
|
protected List<Annotation> |
keyList
A list with all the key annotations
|
static int |
MISMATCH_TYPE
Type for mismatched pairings (where the key and response are co-extensive
but they don't match).
|
protected int |
missing
The number of missing matches.
|
static int |
MISSING_TYPE
Type for missing pairings (where the key was not matched to a response).
|
Set<Annotation> |
missingAnnotations |
static int |
PARTIALLY_CORRECT_TYPE
Type for partially correct pairings (when the key and response match
in type and significant features but the spans are just overlapping and
not identical.
|
Set<Annotation> |
partiallyCorrectAnnotations |
protected int |
partiallyCorrectMatches
The number of partially correct matches.
|
protected List<AnnotationDiffer.Pairing> |
possibleChoices
All the posible choices are added to this list for easy iteration.
|
protected List<List<AnnotationDiffer.Pairing>> |
responseChoices
A list of lists representing all possible choices for each response
|
protected List<Annotation> |
responseList
A list with all the response annotations
|
protected int |
spurious
The number of spurious matches.
|
static int |
SPURIOUS_TYPE
Type for spurious pairings (where the response is not matching any key).
|
Set<Annotation> |
spuriousAnnotations |
Constructor and Description |
---|
AnnotationDiffer() |
AnnotationDiffer(Collection<AnnotationDiffer> differs)
Constructor to be used when you have a collection of AnnotationDiffer
and want to consider it as only one AnnotationDiffer.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addPairing(AnnotationDiffer.Pairing pairing,
int index,
List<List<AnnotationDiffer.Pairing>> listOfPairings)
Adds a new pairing to the internal data structures.
|
List<AnnotationDiffer.Pairing> |
calculateDiff(Collection<Annotation> key,
Collection<Annotation> response)
Computes a diff between two collections of annotations.
|
Set<Annotation> |
getAnnotationsOfType(int type)
A method that returns specific type of annotations
|
String |
getAnnotationType() |
int |
getCorrectMatches()
Gets the number of correct matches.
|
int |
getFalsePositivesLenient()
Gets the number of responses that aren't either correct or partially
correct.
|
int |
getFalsePositivesStrict()
Gets the number of pairings of type
SPURIOUS_TYPE . |
double |
getFMeasureAverage(double beta)
Gets the average of strict and lenient F-Measure values.
|
double |
getFMeasureLenient(double beta)
Gets the lenient F-Measure (F-Measure where the lenient precision and
recall values are used) using the provided parameter as relative weight.
|
double |
getFMeasureStrict(double beta)
Gets the strict F-Measure (the harmonic weighted mean of the strict
precision and the strict recall) using the provided parameter as relative
weight.
|
int |
getKeysCount()
Gets the number of keys provided.
|
List<String> |
getMeasuresRow(Object[] measures,
String title) |
int |
getMissing()
Gets the number of pairings of type
MISSING_TYPE . |
int |
getPartiallyCorrectMatches()
Gets the number of partially correct matches.
|
double |
getPrecisionAverage()
Gets the average of the strict and lenient precision values.
|
double |
getPrecisionLenient()
Gets the lenient precision (where the partial matches are considered as
correct).
|
double |
getPrecisionStrict()
Gets the strict precision (the ratio of correct responses out of all the
provided responses).
|
double |
getRecallAverage()
Gets the average of the strict and lenient recall values.
|
double |
getRecallLenient()
Gets the lenient recall (where the partial matches are considered as
correct).
|
double |
getRecallStrict()
Gets the strict recall (the ratio of key matched to a response out of all
the keys).
|
int |
getResponsesCount()
Gets the number of responses provided.
|
Set<?> |
getSignificantFeaturesSet()
Gets the set of features considered significant for the matching algorithm.
|
int |
getSpurious()
Gets the number of pairings of type
SPURIOUS_TYPE . |
void |
printMissmatches()
Prints to System.out the pairings that are not correct.
|
void |
setSignificantFeaturesSet(Set<String> significantFeaturesSet)
Set the set of features considered significant for the matching algorithm.
|
public Set<Annotation> correctAnnotations
public Set<Annotation> partiallyCorrectAnnotations
public Set<Annotation> missingAnnotations
public Set<Annotation> spuriousAnnotations
public static final int CORRECT_TYPE
public static final int PARTIALLY_CORRECT_TYPE
public static final int MISSING_TYPE
public static final int SPURIOUS_TYPE
public static final int MISMATCH_TYPE
protected int correctMatches
protected int partiallyCorrectMatches
protected int missing
protected int spurious
protected List<Annotation> keyList
protected List<Annotation> responseList
protected List<List<AnnotationDiffer.Pairing>> keyChoices
protected List<List<AnnotationDiffer.Pairing>> responseChoices
protected List<AnnotationDiffer.Pairing> possibleChoices
protected List<AnnotationDiffer.Pairing> finalChoices
public AnnotationDiffer(Collection<AnnotationDiffer> differs)
differs
- collection to be regrouped in one AnnotationDifferpublic AnnotationDiffer()
public List<AnnotationDiffer.Pairing> calculateDiff(Collection<Annotation> key, Collection<Annotation> response)
key
- the collection of key annotations.response
- the collection of response annotations.AnnotationDiffer.Pairing
objects representing the pairing set
that results in the best score.public double getPrecisionStrict()
public double getRecallStrict()
public double getPrecisionLenient()
public double getPrecisionAverage()
public double getRecallLenient()
public double getRecallAverage()
public double getFMeasureStrict(double beta)
beta
- The relative weight of precision and recall. A value of 1
gives equal weights to precision and recall. A value of 0 takes the recall
value completely out of the equation.public double getFMeasureLenient(double beta)
beta
- The relative weight of precision and recall. A value of 1
gives equal weights to precision and recall. A value of 0 takes the recall
value completely out of the equation.public double getFMeasureAverage(double beta)
beta
- The relative weight of precision and recall. A value of 1
gives equal weights to precision and recall. A value of 0 takes the recall
value completely out of the equation.public int getCorrectMatches()
public int getPartiallyCorrectMatches()
public int getMissing()
MISSING_TYPE
.public int getSpurious()
SPURIOUS_TYPE
.public int getFalsePositivesStrict()
SPURIOUS_TYPE
.public int getFalsePositivesLenient()
public int getKeysCount()
public int getResponsesCount()
public void printMissmatches()
protected void addPairing(AnnotationDiffer.Pairing pairing, int index, List<List<AnnotationDiffer.Pairing>> listOfPairings)
pairing
- the pairing to be addedindex
- the index in the list of pairingslistOfPairings
- the list of AnnotationDiffer.Pairing
s where the
pairing should be addedpublic Set<?> getSignificantFeaturesSet()
public void setSignificantFeaturesSet(Set<String> significantFeaturesSet)
significantFeaturesSet
- a Set of String values or null.public Set<Annotation> getAnnotationsOfType(int type)
type
- Set
of Annotation
s.public String getAnnotationType()
Copyright © 2024 GATE. All rights reserved.