³ò
4ÒÇIc           @   sL   d  Z  d d k l Z l Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   s  
Interfaces for labeling tokens with category labels (or X{class
labels}).

L{ClassifierI} is a standard interface for X{single-category
classification}, in which:

    - The set of categories is known.
    - The number of categories is finite.
    - Each text belongs to exactly one category.

L{MultiClassifierI} is a standard interface for C{multi-category
classification}, in which:

    - The set of categories is known.
    - The number of categories is finite.
    - Each text belongs to zero or more categories.
iÿÿÿÿ(   t
   deprecatedt
   overriddent   ClassifierIc           B   se   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d ƒ d „  ƒ Z	 e d ƒ d	 „  ƒ Z
 RS(
   sã  
    A processing interface for labeling tokens with a single category
    label (or X{class}).  Labels are typically C{string}s or
    C{integer}s, but can be any immutable type.  The set of labels
    that the classifier chooses from must be fixed and finite.

    Subclasses must define:
      - L{labels()}
      - either L{classify()} or L{batch_classify()} (or both)
      
    Subclasses may define:
      - either L{prob_classify()} or L{batch_prob_classify()} (or both)
    c         C   s   t  ƒ  ‚ d S(   sv   
        @return: the list of category labels used by this classifier.
        @rtype: C{list} of (immutable)
        N(   t   NotImplementedError(   t   self(    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pyt   labels/   s    c         C   s5   t  |  i ƒ o |  i | g ƒ d Sn
 t ƒ  ‚ d S(   se   
        @return: the most appropriate label for the given featureset.
        @rtype: label
        i    N(   R   t   batch_classifyR   (   R   t
   featureset(    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pyt   classify6   s    c         C   s5   t  |  i ƒ o |  i | g ƒ d Sn
 t ƒ  ‚ d S(   s¡   
        @return: a probability distribution over labels for the given
            featureset.
        @rtype: L{ProbDistI <nltk.probability.ProbDistI>}
        i    N(   R   t   batch_prob_classifyR   (   R   R   (    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pyt   prob_classify@   s    c         C   s(   g  } | D] } | |  i  | ƒ q ~ S(   s»   
        Apply L{self.classify()} to each element of C{featuresets}.  I.e.:

            >>> return [self.classify(fs) for fs in featuresets]

        @rtype: C{list} of I{label}
        (   R   (   R   t   featuresetst   _[1]t   fs(    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pyR   K   s    c         C   s(   g  } | D] } | |  i  | ƒ q ~ S(   sæ   
        Apply L{self.prob_classify()} to each element of C{featuresets}.  I.e.:

            >>> return [self.prob_classify(fs) for fs in featuresets]

        @rtype: C{list} of L{ProbDistI <nltk.probability.ProbDistI>}
        (   R
   (   R   R   R   R   (    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pyR	   U   s    s#   Use .batch_prob_classify() instead.c         C   s   |  i  | ƒ S(   N(   R	   (   R   R   (    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pyt   batch_probdist`   s    s   Use .prob_classify() instead.c         C   s   |  i  | ƒ S(   N(   R
   (   R   R   (    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pyt   probdistc   s    (   t   __name__t
   __module__t   __doc__R   R   R
   R   R	   R    R   R   (    (    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pyR   !   s   		
		
	t   MultiClassifierIc           B   se   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z e d ƒ d „  ƒ Z	 e d ƒ d	 „  ƒ Z
 RS(
   sï  
    A processing interface for labeling tokens with zero or more
    category labels (or X{labels}).  Labels are typically C{string}s
    or C{integer}s, but can be any immutable type.  The set of labels
    that the multi-classifier chooses from must be fixed and finite.

    Subclasses must define:
      - L{labels()}
      - either L{classify()} or L{batch_classify()} (or both)
      
    Subclasses may define:
      - either L{prob_classify()} or L{batch_prob_classify()} (or both)
    c         C   s   t  ƒ  ‚ d S(   sv   
        @return: the list of category labels used by this classifier.
        @rtype: C{list} of (immutable)
        N(   R   (   R   (    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pyR   v   s    c         C   s5   t  |  i ƒ o |  i | g ƒ d Sn
 t ƒ  ‚ d S(   sz   
        @return: the most appropriate set of labels for the given featureset.
        @rtype: C{set} of I{label}
        i    N(   R   R   R   (   R   R   (    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pyR   }   s    c         C   s5   t  |  i ƒ o |  i | g ƒ d Sn
 t ƒ  ‚ d S(   s©   
        @return: a probability distribution over sets of labels for the
            given featureset.
        @rtype: L{ProbDistI <nltk.probability.ProbDistI>}
        i    N(   R   R	   R   (   R   R   (    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pyR
   ‡   s    c         C   s(   g  } | D] } | |  i  | ƒ q ~ S(   sÓ   
        Apply L{self.classify()} to each element of C{featuresets}.  I.e.:

            >>> return [self.classify(fs) for fs in featuresets]
            
        @rtype: C{list} of (C{set} of I{label})
        (   R   (   R   R   R   R   (    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pyR   ’   s    c         C   s(   g  } | D] } | |  i  | ƒ q ~ S(   sò   
        Apply L{self.prob_classify()} to each element of C{featuresets}.  I.e.:

            >>> return [self.prob_classify(fs) for fs in featuresets]
            
        @rtype: C{list} of L{ProbDistI <nltk.probability.ProbDistI>}
        (   R
   (   R   R   R   R   (    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pyR	   œ   s    s#   Use .batch_prob_classify() instead.c         C   s   |  i  | ƒ S(   N(   R	   (   R   R   (    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pyR   §   s    s   Use .prob_classify() instead.c         C   s   |  i  | ƒ S(   N(   R
   (   R   R   (    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pyR   ª   s    (   R   R   R   R   R   R
   R   R	   R    R   R   (    (    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pyR   h   s   		
		
	N(   R   t   nltk.internalsR    R   t   objectR   R   (    (    (    s'   /p/zhu/06/nlp/nltk/nltk/classify/api.pys   <module>   s   G