ó
ù`]c           @  s  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z m Z m	 Z	 m
 Z
 d  d l m Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z d  d	 l m Z d
 Z d e f d „  ƒ  YZ d d „ Z d e f d „  ƒ  YZ d e e e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z  e d ƒ d „  ƒ Z! e d ƒ d „  ƒ Z" d S(   iÿÿÿÿ(   t   unicode_literalsN(   t   find_jar_itert   config_javat   javat   _java_options(   t   TaggerI(   t   ParserI(   t
   TokenizerI(   t   DependencyGraph(   t   Tree(   t   skipu%   http://stanfordnlp.github.io/CoreNLP/t   CoreNLPServerErrorc           B  s   e  Z d  Z RS(   u/   Exceptions associated with the Core NLP server.(   t   __name__t
   __module__t   __doc__(    (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyR      s   i    c         C  sI   t  j  t  j t  j ƒ } | j d |  f ƒ | j ƒ  d } | j ƒ  | S(   Nu    i   (   t   sockett   AF_INETt   SOCK_STREAMt   bindt   getsocknamet   close(   t   portt   sockt   p(    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt   try_port"   s
    
t   CoreNLPServerc           B  sY   e  Z d  Z d Z d d e d d d d „ Z d d d „ Z d „  Z d „  Z	 d „  Z
 RS(	   u0   stanford-corenlp-(\d+)\.(\d+)\.(\d+)-models\.jaru)   stanford-corenlp-(\d+)\.(\d+)\.(\d+)\.jarc   
        sV  | d  k r d d g } n  t t ˆ  j | d d d d d t d | d t ƒƒ } t | d	 ‡  f d
 †  ƒ} | d  k r¾ y t d ƒ } WqÈ t j	 k
 rº t ƒ  } | j
 t | ƒ ƒ qÈ Xn
 t | ƒ d j | ƒ ˆ  _ t t ˆ  j | d d d d d t d | d t ƒd	 ‡  f d †  ƒ}	 | ˆ  _ | |	 f ˆ  _ | ˆ  _ | pLd g ˆ  _ d  S(   Nu   -preloadu(   tokenize,ssplit,pos,lemma,parse,depparset   env_varsu   CORENLPt
   searchpatht   urlt   verboset   is_regext   keyc           s   t  j ˆ  j |  ƒ S(   N(   t   ret   matcht   _JAR(   t
   model_name(   t   self(    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt   <lambda>K   t    i(#  u   http://localhost:{}u   CORENLP_MODELSc           s   t  j ˆ  j |  ƒ S(   N(   R    R!   t   _MODEL_JAR_PATTERN(   R#   (   R$   (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyR%   b   R&   u   -mx2g(   u   CORENLP(    (   u   CORENLP_MODELS(    (   t   Nonet   listR   R"   t   _stanford_urlt   Truet   maxR   R   t   errort   appendt   strt   formatR   R'   R   t
   _classpatht   corenlp_optionst   java_options(
   R$   t   path_to_jart   path_to_models_jarR   R3   R2   R   t   jarst   stanford_jart	   model_jar(    (   R$   s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt   __init__1   sD    
	
			u   devnullc      
   C  sñ  d d l  } d g } |  j r1 | j |  j ƒ n  d j t ƒ } t d |  j d |  j ƒ z. t | d |  j	 d t
 d	 | d
 | ƒ|  _ Wd t d | d |  j ƒ X|  j j ƒ  } | d k	 rõ |  j j ƒ  \ } } t | d j | j d ƒ ƒ ƒ ‚ n  xy t d ƒ D]_ }	 y% | j | j j |  j d ƒ ƒ }
 Wn$ | j j k
 rSt j d ƒ qX|
 j rPqqWt d ƒ ‚ xy t d ƒ D]_ }	 y% | j | j j |  j d ƒ ƒ }
 Wn$ | j j k
 rÏt j d ƒ q~X|
 j r~Pq~q~Wt d ƒ ‚ d S(   už    Starts the CoreNLP server

        :param stdout, stderr: Specifies where CoreNLP output is redirected. Valid values are 'devnull', 'stdout', 'pipe'
        iÿÿÿÿNu/   edu.stanford.nlp.pipeline.StanfordCoreNLPServeru    t   optionsR   t	   classpatht   blockingt   stdoutt   stderru-   Could not start the server. The error was: {}u   asciii   u   livei   u    Could not connect to the server.i<   u   readyu   The server is not ready.(   t   requestsR2   t   extendt   joinR   R   R3   R   R   R1   t   Falset   popent   pollR(   t   communicateR   R0   t   decodet   ranget   gett   compatt   urljoinR   t
   exceptionst   ConnectionErrort   timet   sleept   ok(   R$   R=   R>   R?   t   cmdt   default_optionst
   returncodet   _t
   stderrdatat   it   response(    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt   startl   sJ    			%	%	c         C  s   |  j  j ƒ  |  j  j ƒ  d  S(   N(   RC   t	   terminatet   wait(   R$   (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt   stop¨   s    c         C  s   |  j  ƒ  |  S(   N(   RW   (   R$   (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt	   __enter__¬   s    
c         C  s   |  j  ƒ  t S(   N(   RZ   RB   (   R$   t   exc_typet   exc_valt   exc_tb(    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt   __exit__±   s    
N(   R   R   R'   R"   R(   RB   R9   RW   RZ   R[   R_   (    (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyR   ,   s   4<		t   GenericCoreNLPParserc           B  sƒ   e  Z d  Z d d d d „ Z d „  Z d d „ Z d d d „ Z e d d „ Z	 d	 „  Z
 d d
 „ Z d „  Z d „  Z d „  Z RS(   u    Interface to the CoreNLP Parser.u   http://localhost:9000u   utf8c         C  sU   d d  l  } | |  _ | |  _ | d k r9 t d ƒ ‚ n  | |  _ | j ƒ  |  _ d  S(   Niÿÿÿÿu   posu   neru+   tagtype must be either 'pos', 'ner' or None(   u   posu   nerN(   R?   R   t   encodingR(   t
   ValueErrort   tagtypet   Sessiont   session(   R$   R   Ra   Rc   R?   (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyR9   ¹   s    			c         O  s#   d „  | Dƒ } |  j  | | | Ž S(   uÄ  Parse multiple sentences.

        Takes multiple sentences as a list where each sentence is a list of
        words. Each sentence will be automatically tagged with this
        CoreNLPParser instance's tagger.

        If a whitespace exists inside a token, then the token will be treated as
        several tokens.

        :param sentences: Input sentences to parse
        :type sentences: list(list(str))
        :rtype: iter(iter(Tree))
        c         s  s   |  ] } d  j  | ƒ Vq d S(   u    N(   RA   (   t   .0t   words(    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pys	   <genexpr>Õ   s    (   t   raw_parse_sents(   R$   t	   sentencest   argst   kwargs(    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt   parse_sentsÆ   s    c         O  sB   i d d 6} | j  | p i  ƒ t |  j | g d | | | Žƒ S(   u  Parse a sentence.

        Takes a sentence as a string; before parsing, it will be automatically
        tokenized and tagged by the CoreNLP Parser.

        :param sentence: Input sentence to parse
        :type sentence: str
        :rtype: iter(Tree)
        u   falseu   tokenize.whitespacet
   properties(   t   updatet   nextRh   (   R$   t   sentenceRm   Rj   Rk   t   default_properties(    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt	   raw_parseØ   s
    
i<   c         C  s   i d d 6d j  d |  j ƒ d 6} | j | p2 i  ƒ |  j j |  j d i t j | ƒ d 6d | j |  j	 ƒ d	 | ƒ} | j
 ƒ  | j ƒ  S(
   Nu   jsonu   outputFormatu,   tokenize,pos,lemma,ssplit,{parser_annotator}t   parser_annotatoru
   annotatorst   paramsu
   propertiest   datat   timeout(   R0   Rs   Rn   Re   t   postR   t   jsont   dumpst   encodeRa   t   raise_for_status(   R$   Ru   Rm   Rv   Rq   RV   (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt   api_callë   s    				
c   
      o  st   i d d 6} | j  | p i  ƒ |  j d j | ƒ d | ƒ} x/ | d D]# } |  j | ƒ }	 t |	 g ƒ VqI Wd S(   u  Parse multiple sentences.

        Takes multiple sentences as a list of strings. Each sentence will be
        automatically tokenized and tagged.

        :param sentences: Input sentences to parse.
        :type sentences: list(str)
        :rtype: iter(iter(Tree))

        u   trueu   ssplit.eolonlyu   
Rm   u	   sentencesN(   Rn   R|   RA   t	   make_treet   iter(
   R$   Ri   R   Rm   Rj   Rk   Rq   t   parsed_datat   parsed_sentt   tree(    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyRh      s    
c         o  s<   |  j  | | | Ž } x  | d D] } |  j | ƒ Vq  Wd S(   u  Parse a piece of text.

        The text might contain several sentences which will be split by CoreNLP.

        :param str text: text to be split.
        :returns: an iterable of syntactic structures.  # TODO: should it be an iterable of iterables?

        u	   sentencesN(   R|   R}   (   R$   t   textRj   Rk   R   t   parse(    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt
   parse_text#  s    	c         c  sv   i d d 6} | j  | p i  ƒ |  j | d | ƒ} x: | d D]. } x% | d D] } | d ph | d VqQ Wq@ Wd S(	   uÅ  Tokenize a string of text.

        >>> parser = CoreNLPParser(url='http://localhost:9000')

        >>> text = 'Good muffins cost $3.88\nin New York.  Please buy me\ntwo of them.\nThanks.'
        >>> list(parser.tokenize(text))
        ['Good', 'muffins', 'cost', '$', '3.88', 'in', 'New', 'York', '.', 'Please', 'buy', 'me', 'two', 'of', 'them', '.', 'Thanks', '.']

        >>> s = "The colour of the wall is blue."
        >>> list(
        ...     parser.tokenize(
        ...         'The colour of the wall is blue.',
        ...             properties={'tokenize.options': 'americanize=true'},
        ...     )
        ... )
        ['The', 'color', 'of', 'the', 'wall', 'is', 'blue', '.']

        u   tokenize,ssplitu
   annotatorsRm   u	   sentencesu   tokensu   originalTextu   wordN(   Rn   R|   (   R$   R‚   Rm   Rq   t   resultRp   t   token(    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt   tokenize1  s    c         C  s4   d „  | Dƒ } g  |  j  | ƒ D] } | d ^ q  S(   u  
        Tag multiple sentences.

        Takes multiple sentences as a list where each sentence is a list of
        tokens.
        
        :param sentences: Input sentences to tag
        :type sentences: list(list(str))
        :rtype: list(list(tuple(str, str))
        c         s  s   |  ] } d  j  | ƒ Vq d S(   u    N(   RA   (   Rf   Rg   (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pys	   <genexpr>Z  s    i    (   t   raw_tag_sents(   R$   Ri   (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt	   tag_sentsN  s    c         C  s   |  j  | g ƒ d S(   uJ  
        Tag a list of tokens.

        :rtype: list(tuple(str, str))

        >>> parser = CoreNLPParser(url='http://localhost:9000', tagtype='ner')
        >>> tokens = 'Rami Eid is studying at Stony Brook University in NY'.split()
        >>> parser.tag(tokens)
        [('Rami', 'PERSON'), ('Eid', 'PERSON'), ('is', 'O'), ('studying', 'O'), ('at', 'O'), ('Stony', 'ORGANIZATION'),
        ('Brook', 'ORGANIZATION'), ('University', 'ORGANIZATION'), ('in', 'O'), ('NY', 'O')]

        >>> parser = CoreNLPParser(url='http://localhost:9000', tagtype='pos')
        >>> tokens = "What is the airspeed of an unladen swallow ?".split()
        >>> parser.tag(tokens)
        [('What', 'WP'), ('is', 'VBZ'), ('the', 'DT'),
        ('airspeed', 'NN'), ('of', 'IN'), ('an', 'DT'),
        ('unladen', 'JJ'), ('swallow', 'VB'), ('?', '.')]
        i    (   R‰   (   R$   Rp   (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt   tag]  s    c         c  sª   i d d 6d d 6} |  j  d k s) t ‚ | d c |  j  7<xg | D]_ } |  j | d | ƒ} g  | d D]4 } g  | d	 D] } | d
 | |  j  f ^ qz ^ qi VqC Wd S(   u  
        Tag multiple sentences.

        Takes multiple sentences as a list where each sentence is a string.
        
        :param sentences: Input sentences to tag
        :type sentences: list(str)
        :rtype: list(list(list(tuple(str, str)))
        u   trueu   ssplit.isOneSentenceu   tokenize,ssplit,u
   annotatorsu   posu   nerRm   u	   sentencesu   tokensu   wordN(   u   posu   ner(   Rc   t   AssertionErrorR|   (   R$   Ri   Rq   Rp   t   tagged_datat   tagged_sentenceR†   (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyRˆ   r  s    

N(   R   R   R   R(   R9   Rl   Rr   R|   RB   Rh   R„   R‡   R‰   RŠ   Rˆ   (    (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyR`   ¶   s   	"			t   CoreNLPParserc           B  s#   e  Z d  Z d Z d Z d „  Z RS(   uN  
    >>> parser = CoreNLPParser(url='http://localhost:9000')

    >>> next(
    ...     parser.raw_parse('The quick brown fox jumps over the lazy dog.')
    ... ).pretty_print()  # doctest: +NORMALIZE_WHITESPACE
                         ROOT
                          |
                          S
           _______________|__________________________
          |                         VP               |
          |                _________|___             |
          |               |             PP           |
          |               |     ________|___         |
          NP              |    |            NP       |
      ____|__________     |    |     _______|____    |
     DT   JJ    JJ   NN  VBZ   IN   DT      JJ   NN  .
     |    |     |    |    |    |    |       |    |   |
    The quick brown fox jumps over the     lazy dog  .

    >>> (parse_fox, ), (parse_wolf, ) = parser.raw_parse_sents(
    ...     [
    ...         'The quick brown fox jumps over the lazy dog.',
    ...         'The quick grey wolf jumps over the lazy fox.',
    ...     ]
    ... )

    >>> parse_fox.pretty_print()  # doctest: +NORMALIZE_WHITESPACE
                         ROOT
                          |
                          S
           _______________|__________________________
          |                         VP               |
          |                _________|___             |
          |               |             PP           |
          |               |     ________|___         |
          NP              |    |            NP       |
      ____|__________     |    |     _______|____    |
     DT   JJ    JJ   NN  VBZ   IN   DT      JJ   NN  .
     |    |     |    |    |    |    |       |    |   |
    The quick brown fox jumps over the     lazy dog  .

    >>> parse_wolf.pretty_print()  # doctest: +NORMALIZE_WHITESPACE
                         ROOT
                          |
                          S
           _______________|__________________________
          |                         VP               |
          |                _________|___             |
          |               |             PP           |
          |               |     ________|___         |
          NP              |    |            NP       |
      ____|_________      |    |     _______|____    |
     DT   JJ   JJ   NN   VBZ   IN   DT      JJ   NN  .
     |    |    |    |     |    |    |       |    |   |
    The quick grey wolf jumps over the     lazy fox  .

    >>> (parse_dog, ), (parse_friends, ) = parser.parse_sents(
    ...     [
    ...         "I 'm a dog".split(),
    ...         "This is my friends ' cat ( the tabby )".split(),
    ...     ]
    ... )

    >>> parse_dog.pretty_print()  # doctest: +NORMALIZE_WHITESPACE
            ROOT
             |
             S
      _______|____
     |            VP
     |    ________|___
     NP  |            NP
     |   |         ___|___
    PRP VBP       DT      NN
     |   |        |       |
     I   'm       a      dog

    >>> parse_friends.pretty_print()  # doctest: +NORMALIZE_WHITESPACE
         ROOT
          |
          S
      ____|___________
     |                VP
     |     ___________|_____________
     |    |                         NP
     |    |                  _______|_________
     |    |                 NP               PRN
     |    |            _____|_______      ____|______________
     NP   |           NP            |    |        NP         |
     |    |     ______|_________    |    |     ___|____      |
     DT  VBZ  PRP$   NNS       POS  NN -LRB-  DT       NN  -RRB-
     |    |    |      |         |   |    |    |        |     |
    This  is   my  friends      '  cat -LRB- the     tabby -RRB-

    >>> parse_john, parse_mary, = parser.parse_text(
    ...     'John loves Mary. Mary walks.'
    ... )

    >>> parse_john.pretty_print()  # doctest: +NORMALIZE_WHITESPACE
          ROOT
           |
           S
      _____|_____________
     |          VP       |
     |      ____|___     |
     NP    |        NP   |
     |     |        |    |
    NNP   VBZ      NNP   .
     |     |        |    |
    John loves     Mary  .

    >>> parse_mary.pretty_print()  # doctest: +NORMALIZE_WHITESPACE
          ROOT
           |
           S
      _____|____
     NP    VP   |
     |     |    |
    NNP   VBZ   .
     |     |    |
    Mary walks  .

    Special cases
    -------------

    >>> next(
    ...     parser.raw_parse(
    ...         'NASIRIYA, Iraqâ€”Iraqi doctors who treated former prisoner of war '
    ...         'Jessica Lynch have angrily dismissed claims made in her biography '
    ...         'that she was raped by her Iraqi captors.'
    ...     )
    ... ).height()
    20

    >>> next(
    ...     parser.raw_parse(
    ...         "The broader Standard & Poor's 500 Index <.SPX> was 0.46 points lower, or "
    ...         '0.05 percent, at 997.02.'
    ...     )
    ... ).height()
    9

    u   pennu   parsec         C  s   t  j | d ƒ S(   Nu   parse(   R	   t
   fromstring(   R$   R…   (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyR}   #  s    (   R   R   R   t   _OUTPUT_FORMATRs   R}   (    (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyRŽ     s   t   CoreNLPDependencyParserc           B  s#   e  Z d  Z d Z d Z d „  Z RS(   ui  Dependency parser.

    >>> dep_parser = CoreNLPDependencyParser(url='http://localhost:9000')

    >>> parse, = dep_parser.raw_parse(
    ...     'The quick brown fox jumps over the lazy dog.'
    ... )
    >>> print(parse.to_conll(4))  # doctest: +NORMALIZE_WHITESPACE
    The     DT      4       det
    quick   JJ      4       amod
    brown   JJ      4       amod
    fox     NN      5       nsubj
    jumps   VBZ     0       ROOT
    over    IN      9       case
    the     DT      9       det
    lazy    JJ      9       amod
    dog     NN      5       nmod
    .       .       5       punct

    >>> print(parse.tree())  # doctest: +NORMALIZE_WHITESPACE
    (jumps (fox The quick brown) (dog over the lazy) .)

    >>> for governor, dep, dependent in parse.triples():
    ...     print(governor, dep, dependent)  # doctest: +NORMALIZE_WHITESPACE
        ('jumps', 'VBZ') nsubj ('fox', 'NN')
        ('fox', 'NN') det ('The', 'DT')
        ('fox', 'NN') amod ('quick', 'JJ')
        ('fox', 'NN') amod ('brown', 'JJ')
        ('jumps', 'VBZ') nmod ('dog', 'NN')
        ('dog', 'NN') case ('over', 'IN')
        ('dog', 'NN') det ('the', 'DT')
        ('dog', 'NN') amod ('lazy', 'JJ')
        ('jumps', 'VBZ') punct ('.', '.')

    >>> (parse_fox, ), (parse_dog, ) = dep_parser.raw_parse_sents(
    ...     [
    ...         'The quick brown fox jumps over the lazy dog.',
    ...         'The quick grey wolf jumps over the lazy fox.',
    ...     ]
    ... )
    >>> print(parse_fox.to_conll(4))  # doctest: +NORMALIZE_WHITESPACE
    The DT      4       det
    quick       JJ      4       amod
    brown       JJ      4       amod
    fox NN      5       nsubj
    jumps       VBZ     0       ROOT
    over        IN      9       case
    the DT      9       det
    lazy        JJ      9       amod
    dog NN      5       nmod
    .   .       5       punct

    >>> print(parse_dog.to_conll(4))  # doctest: +NORMALIZE_WHITESPACE
    The DT      4       det
    quick       JJ      4       amod
    grey        JJ      4       amod
    wolf        NN      5       nsubj
    jumps       VBZ     0       ROOT
    over        IN      9       case
    the DT      9       det
    lazy        JJ      9       amod
    fox NN      5       nmod
    .   .       5       punct

    >>> (parse_dog, ), (parse_friends, ) = dep_parser.parse_sents(
    ...     [
    ...         "I 'm a dog".split(),
    ...         "This is my friends ' cat ( the tabby )".split(),
    ...     ]
    ... )
    >>> print(parse_dog.to_conll(4))  # doctest: +NORMALIZE_WHITESPACE
    I   PRP     4       nsubj
    'm  VBP     4       cop
    a   DT      4       det
    dog NN      0       ROOT

    >>> print(parse_friends.to_conll(4))  # doctest: +NORMALIZE_WHITESPACE
    This        DT      6       nsubj
    is  VBZ     6       cop
    my  PRP$    4       nmod:poss
    friends     NNS     6       nmod:poss
    '   POS     4       case
    cat NN      0       ROOT
    -LRB-       -LRB-   9       punct
    the DT      9       det
    tabby       NN      6       appos
    -RRB-       -RRB-   9       punct

    >>> parse_john, parse_mary, = dep_parser.parse_text(
    ...     'John loves Mary. Mary walks.'
    ... )

    >>> print(parse_john.to_conll(4))  # doctest: +NORMALIZE_WHITESPACE
    John        NNP     2       nsubj
    loves       VBZ     0       ROOT
    Mary        NNP     2       dobj
    .   .       2       punct

    >>> print(parse_mary.to_conll(4))  # doctest: +NORMALIZE_WHITESPACE
    Mary        NNP     2       nsubj
    walks       VBZ     0       ROOT
    .   .       2       punct

    Special cases
    -------------

    Non-breaking space inside of a token.

    >>> len(
    ...     next(
    ...         dep_parser.raw_parse(
    ...             'Anhalt said children typically treat a 20-ounce soda bottle as one '
    ...             'serving, while it actually contains 2 1/2 servings.'
    ...         )
    ...     ).nodes
    ... )
    21

    Phone  numbers.

    >>> len(
    ...     next(
    ...         dep_parser.raw_parse('This is not going to crash: 01 111 555.')
    ...     ).nodes
    ... )
    10

    >>> print(
    ...     next(
    ...         dep_parser.raw_parse('The underscore _ should not simply disappear.')
    ...     ).to_conll(4)
    ... )  # doctest: +NORMALIZE_WHITESPACE
    The         DT  3   det
    underscore  VBP 3   amod
    _           NN  7   nsubj
    should      MD  7   aux
    not         RB  7   neg
    simply      RB  7   advmod
    disappear   VB  0   ROOT
    .           .   7   punct

    >>> print(
    ...     '\n'.join(
    ...         next(
    ...             dep_parser.raw_parse(
    ...                 'for all of its insights into the dream world of teen life , and its electronic expression through '
    ...                 'cyber culture , the film gives no quarter to anyone seeking to pull a cohesive story out of its 2 '
    ...                 '1/2-hour running time .'
    ...             )
    ...         ).to_conll(4).split('\n')[-8:]
    ...     )
    ... )
    its	PRP$	40	nmod:poss
    2Â 1/2	CD	40	nummod
    -	:	40	punct
    hour	NN	31	nmod
    running	VBG	42	amod
    time	NN	40	dep
    .	.	24	punct
    <BLANKLINE>

    u	   conll2007u   depparsec         C  s&   t  d „  t t | ƒ ƒ Dƒ d d ƒS(   Nc         s  s"   |  ] } d  j  | d ƒ Vq d S(   u    i   N(   RA   (   Rf   t   n_items(    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pys	   <genexpr>Ò  s   t   cell_separatoru    (   R   t   sortedt	   transform(   R$   R…   (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyR}   Î  s    (   R   R   R   R   Rs   R}   (    (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyR‘   '  s   ¢c         c  sy   xr |  d D]f } | d } |  d | d } | d | d | d | d | d d t  | d	 ƒ | d
 d d f Vq Wd  S(   Nu   basicDependenciesu	   dependentu   tokensi   u   _u   wordu   lemmau   posu   governoru   dep(   R/   (   Rp   t
   dependencyt   dependent_indexR†   (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyR•   Ù  s    
u   Skipping all CoreNLP tests.c         C  s…   d d l  m } y t d d ƒ a Wn t k
 rD } | d ƒ ‚ n Xy t j ƒ  Wn+ t k
 r€ } | d j | j ƒ ƒ ‚ n Xd  S(   Niÿÿÿÿ(   t   SkipTestR   i(#  u$   Could not instantiate CoreNLPServer.uh   Skipping CoreNLP tests because the server could not be started. Make sure that the 9000 port is free. {}(	   t   noseR˜   R   t   servert   LookupErrorRW   R   R0   t   strerror(   t   moduleR˜   t   e(    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt   setup_moduleð  s    c         C  s   t  j ƒ  d  S(   N(   Rš   RZ   (   R   (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt   teardown_module  s    (#   t
   __future__R    R    Rx   RM   R   t   nltk.internalsR   R   R   R   t   nltk.tag.apiR   t   nltk.parse.apiR   t   nltk.tokenize.apiR   t   nltk.parse.dependencygraphR   t	   nltk.treeR	   t   unittestR
   R*   t   EnvironmentErrorR   R   t   objectR   R`   RŽ   R‘   R•   RŸ   R    (    (    (    s1   lib/python2.7/site-packages/nltk/parse/corenlp.pyt   <module>
   s*   "
ŠÙ˜²	