nltk.metrics.AnnotationTask¶
- class nltk.metrics.AnnotationTask[source]¶
Bases:
object
Represents an annotation task, i.e. people assign labels to items.
Notation tries to match notation in Artstein and Poesio (2007).
In general, coders and items can be represented as any hashable object. Integers, for example, are fine, though strings are more readable. Labels must support the distance functions applied to them, so e.g. a string-edit-distance makes no sense if your labels are integers, whereas interval distance needs numeric values. A notable case of this is the MASI metric, which requires Python sets.
- __init__(data=None, distance=<function binary_distance>)[source]¶
Initialize an annotation task.
The data argument can be None (to create an empty annotation task) or a sequence of 3-tuples, each representing a coder’s labeling of an item:
(coder,item,label)
The distance argument is a function taking two arguments (labels) and producing a numerical distance. The distance from a label to itself should be zero:
distance(l,l) = 0
- load_array(array)[source]¶
Load an sequence of annotation results, appending to any data already loaded.
- The argument is a sequence of 3-tuples, each representing a coder’s labeling of an item:
(coder,item,label)
- N(**kwargs)[source]¶
Implements the “n-notation” used in Artstein and Poesio (2007)
@deprecated: Use Nk, Nik or Nck instead
- Do_Kw_pairwise(cA, cB, max_distance=1.0)[source]¶
The observed disagreement for the weighted kappa coefficient.