ó
ù`]c           @   s    d  d l  m Z d d „ Z d S(   iÿÿÿÿ(   t   divisionc         C   sd   | d k r |  } n |  j | ƒ s* t ‚ d t | |  @ƒ t | | @ƒ t t | ƒ t |  ƒ ƒ S(   sF  
    Return the Alignment Error Rate (AER) of an alignment
    with respect to a "gold standard" reference alignment.
    Return an error rate between 0.0 (perfect alignment) and 1.0 (no
    alignment).

        >>> from nltk.translate import Alignment
        >>> ref = Alignment([(0, 0), (1, 1), (2, 2)])
        >>> test = Alignment([(0, 0), (1, 2), (2, 1)])
        >>> alignment_error_rate(ref, test) # doctest: +ELLIPSIS
        0.6666666666666667

    :type reference: Alignment
    :param reference: A gold standard alignment (sure alignments)
    :type hypothesis: Alignment
    :param hypothesis: A hypothesis alignment (aka. candidate alignments)
    :type possible: Alignment or None
    :param possible: A gold standard reference of possible alignments
        (defaults to *reference* if None)
    :rtype: float or None
    g      ð?N(   t   Nonet   issubsett   AssertionErrort   lent   float(   t	   referencet
   hypothesist   possible(    (    s5   lib/python2.7/site-packages/nltk/translate/metrics.pyt   alignment_error_rate   s
    	!N(   t
   __future__R    R   R	   (    (    (    s5   lib/python2.7/site-packages/nltk/translate/metrics.pyt   <module>	   s   