³ò
ŒB_Kc           @   s\   d  Z  d „  Z e d j o< d d k l Z d d d d g Z e e i d	 ƒ e ƒ n d
 S(   s.   
A utility for displaying lexical dispersion.
c         C   sM  y d d k  } Wn t j
 o t d ƒ ‚ n Xt |  ƒ }  | i ƒ  g  } t t |  ƒ ƒ D]E } t t | ƒ ƒ D], } |  | | | j o | | | f qu qu q_ ~ } | o t | Œ  \ } } n d } } | i | | d d d ƒ| i	 t t | ƒ ƒ | d d ƒ| i
 d t | ƒ ƒ | i d	 ƒ | i d
 ƒ | i ƒ  d S(   sÂ   
    Generate a lexical dispersion plot.

    @param text: The source text
    @type text: C{list} or C{enum} of C{str}
    @param words: The target words
    @type words: C{list} of C{str}
    iÿÿÿÿNsX   The plot function requires the matplotlib package.See http://matplotlib.sourceforge.net/s   b|t   scalexgš™™™™™¹?t   colort   bs   Lexical Dispersion Plots   Word Offset(    (   t   pylabt   ImportErrort
   ValueErrort   listt   reverset   ranget   lent   zipt   plott   ytickst   ylimt   titlet   xlabelt   show(   t   textt   wordsR   t   _[1]t   xt   yt   points(    (    s*   /p/zhu/06/nlp/nltk/nltk/draw/dispersion.pyt   dispersion_plot   s$    

2
"t   __main__iÿÿÿÿ(   t	   gutenbergt   Elinort   Mariannet   Edwardt
   Willoughbys   austen-sense.txtN(   t   __doc__R   t   __name__t   nltk.corpusR   R   (    (    (    s*   /p/zhu/06/nlp/nltk/nltk/draw/dispersion.pys   <module>
   s
   	 