³ò
4ÒÇIc           @   sÆ   d  d k  Z  d  d k l Z d  d k l Z d d „ Z d d „ Z d „  Z e d ƒ d	 „  ƒ Z e d
 ƒ d d „ ƒ Z	 e d ƒ d d „ ƒ Z
 e d ƒ d d „ ƒ Z e d ƒ d d „ ƒ Z d S(   iÿÿÿÿN(   t
   deprecated(   t   accuracyt   /c         C   sJ   |  i  | ƒ } | d j o  |  |  |  | d i ƒ  f Sn |  d f Sd S(   sÛ  
    Given the string representation of a tagged token, return the
    corresponding tuple representation.  The rightmost occurence of
    C{sep} in C{s} will be used to divide C{s} into a word string and
    a tag string.  If C{sep} does not occur in C{s}, return
    C{(s, None)}.

    @type s: C{str}
    @param s: The string representaiton of a tagged token.
    @type sep: C{str}
    @param sep: The separator string used to separate word strings
        from tags.
    i    i   N(   t   rfindt   uppert   None(   t   st   sept   loc(    (    s#   /p/zhu/06/nlp/nltk/nltk/tag/util.pyt	   str2tuple   s     c         C   sM   |  \ } } | d j o | Sn) | | j p
 t d ‚ d | | | f Sd S(   s  
    Given the tuple representation of a tagged token, return the
    corresponding string representation.  This representation is
    formed by concatenating the token's word string, followed by the
    separator, followed by the token's tag.  (If the tag is None,
    then just return the bare word string.)
    
    @type tagged_token: C{(str, str)}
    @param tagged_token: The tuple representation of a tagged token.
    @type sep: C{str}
    @param sep: The separator string used to separate word strings
        from tags.
    s   tag may not contain sep!s   %s%s%sN(   R   t   AssertionError(   t   tagged_tokenR   t   wordt   tag(    (    s#   /p/zhu/06/nlp/nltk/nltk/tag/util.pyt	   tuple2str"   s
    c         C   s%   g  } |  D] \ } } | | q ~ S(   s  
    Given a tagged sentence, return an untagged version of that
    sentence.  I.e., return a list containing the first element
    of each tuple in C{tagged_sentence}.

    >>> untag([('John', 'NNP'), ('saw', 'VBD'), ('Mary', 'NNP')]
    ['John', 'saw', 'mary']
    (    (   t   tagged_sentencet   _[1]t   wt   t(    (    s#   /p/zhu/06/nlp/nltk/nltk/tag/util.pyt   untag7   s    	s   use tagger.evaluate(gold)c         C   s   |  i  | ƒ S(   N(   t   evaluate(   t   taggert   gold(    (    s#   /p/zhu/06/nlp/nltk/nltk/tag/util.pyR   B   s    s'   Use nltk.tag.str2tuple(s, sep) instead.c         C   s   t  |  | ƒ S(   N(   R	   (   R   R   (    (    s#   /p/zhu/06/nlp/nltk/nltk/tag/util.pyt	   tag2tupleJ   s    s<   Use [nltk.tag.str2tuple(t, sep) for t in s.split()] instead.c         C   s.   g  } |  i  ƒ  D] } | t | | ƒ q ~ S(   N(   t   splitR	   (   R   R   R   R   (    (    s#   /p/zhu/06/nlp/nltk/nltk/tag/util.pyt   string2tagsN   s    s<   Use ' '.join(nltk.tag.tuple2str(w, sep) for w in t) instead.c            s   d i  ‡  f d †  |  Dƒ ƒ S(   Nt    c         3   s"   x |  ] } t  | ˆ  ƒ Vq Wd  S(   N(   R   (   t   .0R   (   R   (    s#   /p/zhu/06/nlp/nltk/nltk/tag/util.pys	   <genexpr>T   s    (   t   join(   R   R   (    (   R   s#   /p/zhu/06/nlp/nltk/nltk/tag/util.pyt   tags2stringR   s    s?   Use [nltk.tag.str2tuple(t, sep)[0] for t in s.split()] instead.c         C   s2   g  } |  i  ƒ  D] } | t | | ƒ d q ~ S(   Ni    (   R   R	   (   R   R   R   R   (    (    s#   /p/zhu/06/nlp/nltk/nltk/tag/util.pyt   string2wordsV   s    (   t   ret   nltk.internalsR    t   nltk.metricsR   t	   _accuracyR	   R   R   R   R   R   R   (    (    (    s#   /p/zhu/06/nlp/nltk/nltk/tag/util.pys   <module>	   s   					