class_docstr: 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.
class_docstr_tok: ["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","."]
docstr: Agreement between two coders on a given item
docstr_tok: ["Agreement","between","two","coders","on","a","given","item"]
code: def agr(self, cA, cB, i, data=None):
      """Agreement between two coders on a given item"""
      data = data or self.data
      # cfedermann: we don't know what combination of coder/item will come
      # first in x; to avoid StopIteration problems due to assuming an order
      # cA,cB, we allow either for k1 and then look up the missing as k2.
      k1 = next(
          x for x in data if x["coder"] in (cA, cB) and x["item"] == i
      )
      if k1["coder"] == cA:
          k2 = next(
              x for x in data if x["coder"] == cB and x["item"] == i
          )
      else:
          k2 = next(
              x for x in data if x["coder"] == cA and x["item"] == i
          )
  
      ret = 1.0 - float(self.distance(k1["labels"], k2["labels"]))
      log.debug(
          "Observed agreement between %s and %s on %s: %f",
          cA,
          cB,
          i,
          ret,
      )
      log.debug(
          'Distance between "%r" and "%r": %f',
          k1["labels"],
          k2["labels"],
          1.0 - ret,
      )
      return ret
  
imports: import logging
  from itertools import groupby
  from operator import itemgetter
  from nltk.internals import deprecated
  from nltk.metrics.distance import binary_distance
  from nltk.probability import ConditionalFreqDist, FreqDist
label_desc: Use image node_id 4 for calling the AnnotationTask obj's underlying member method code with example usage: obj.agr(cA, cB, i, data) and returns: ret