łň
B_Kc           @   s6   d  d k  l Z d  d k Z d e f d     YZ d S(   i˙˙˙˙(   t   ParserINt   ChunkParserIc           B   s    e  Z d  Z d   Z d   Z RS(   s6  
    A processing interface for identifying non-overlapping groups in
    unrestricted text.  Typically, chunk parsers are used to find base
    syntactic constituants, such as base noun phrases.  Unlike
    L{ParserI}, C{ChunkParserI} guarantees that the C{parse} method
    will always generate a parse.
    c         C   s   d p
 t  d  d S(   só   
        @return: the best chunk structure for the given tokens
        and return a tree.
        
        @param tokens: The list of (word, tag) tokens to be chunked.
        @type tokens: C{list} of L{tuple}
        @rtype: L{Tree}
        i    s%   ChunkParserI is an abstract interfaceN(   t   AssertionError(   t   selft   tokens(    (    s$   /p/zhu/06/nlp/nltk/nltk/chunk/api.pyt   parse   s    	c         C   sF   t  i i i   } x- | D]% } | i | |  i | i     q W| S(   sĎ  
        Score the accuracy of the chunker against the gold standard.
        Remove the chunking the gold standard text, rechunk it using
        the chunker, and return a L{ChunkScore<nltk.chunk.util.ChunkScore>}
        object reflecting the performance of this chunk peraser.

        @type gold: C{list} of L{Tree}
        @param gold: The list of chunked sentences to score the chunker on.
        @rtype:  L{ChunkScore<nltk.chunk.util.ChunkScore>}
        (   t   nltkt   chunkt   utilt
   ChunkScoret   scoreR   t   leaves(   R   t   goldt
   chunkscoret   correct(    (    s$   /p/zhu/06/nlp/nltk/nltk/chunk/api.pyt   evaluate#   s
     #(   t   __name__t
   __module__t   __doc__R   R   (    (    (    s$   /p/zhu/06/nlp/nltk/nltk/chunk/api.pyR      s   	(   t
   nltk.parseR    R   R   (    (    (    s$   /p/zhu/06/nlp/nltk/nltk/chunk/api.pys   <module>   s   