ó
ù`]c           @  s"  d  Z  d d l m Z m Z d d l m Z d d l m Z d d l m	 Z	 d d l
 Z
 d d l Z d d l m Z d d l m Z d d	 l m Z e d
 e f d „  ƒ  Yƒ Z d e f d „  ƒ  YZ d „  Z e d „ Z d „  Z d „  Z d „  Z d Z d Z d Z e d k re ƒ  n  d S(   u˜   
Tools for reading and writing dependency trees.
The input is assumed to be in Malt-TAB format
(http://stp.lingfil.uu.se/~nivre/research/MaltXML.html).
iÿÿÿÿ(   t   print_functiont   unicode_literals(   t   defaultdict(   t   chain(   t   pformatN(   t   string_types(   t   Tree(   t   python_2_unicode_compatiblet   DependencyGraphc           B  s(  e  Z d  Z d d e d d d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z d „  Z d „  Z e e d d d „ ƒ Z d „  Z d „  Z d „  Z d e d d d „ Z e d „ Z d „  Z d „  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z  RS(   uQ   
    A container for the nodes and labelled edges of a dependency structure.
    u   ROOTc      
   C  sv   t  d „  ƒ |  _ |  j d j i d d 6d d 6d d 6ƒ d |  _ | rr |  j | d | d | d	 | d
 | ƒn  d S(   u¥  Dependency graph.

        We place a dummy `TOP` node with the index 0, since the root node is
        often assigned 0 as its head. This also means that the indexing of the
        nodes corresponds directly to the Malt-TAB format, which starts at 1.

        If zero-based is True, then Malt-TAB-like input with node numbers
        starting at 0 and the root node assigned -1 (as produced by, e.g.,
        zpar).

        :param str cell_separator: the cell separator. If not provided, cells
        are split by whitespace.

        :param str top_relation_label: the label by which the top relation is
        identified, for examlple, `ROOT`, `null` or `TOP`.

        c           S  sI   i	 d  d 6d  d 6d  d 6d  d 6d  d 6d  d 6d  d 6t t ƒ d 6d  d	 6S(
   Nu   addressu   wordu   lemmau   ctagu   tagu   featsu   headu   depsu   rel(   t   NoneR   t   list(    (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   <lambda>C   s   i    u   TOPu   ctagu   tagu   addresst   cell_extractort
   zero_basedt   cell_separatort   top_relation_labelN(   R   t   nodest   updateR	   t   roott   _parse(   t   selft   tree_strR   R   R   R   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   __init__)   s    )	c         C  s   |  j  | =d S(   uw   
        Removes the node with the given address.  References
        to this node in others will still exist.
        N(   R   (   R   t   address(    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   remove_by_address]   s    c         C  sl   xe |  j  j ƒ  D]T } g  } x; | d D]/ } | | k rI | j | ƒ q' | j | ƒ q' W| | d <q Wd S(   up   
        Redirects arcs to any of the nodes in the originals list
        to the redirect node address.
        u   depsN(   R   t   valuest   append(   R   t	   originalst   redirectt   nodet   new_depst   dep(    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   redirect_arcsd   s    c         C  sL   |  j  | d } |  j  | d j | g  ƒ |  j  | d | j | ƒ d S(   uw   
        Adds an arc from the node specified by head_address to the
        node specified by the mod address.
        u   relu   depsN(   R   t
   setdefaultR   (   R   t   head_addresst   mod_addresst   relation(    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   add_arcr   s    c         C  s–   x |  j  j ƒ  D]~ } xu |  j  j ƒ  D]d } | d | d k r& | d d k r& | d } | d j | g  ƒ | d | j | d ƒ q& q& Wq Wd S(   ur   
        Fully connects all non-root nodes.  All nodes are set to be dependents
        of the root node.
        u   addressu   relu   TOPu   depsN(   R   R   R!   R   (   R   t   node1t   node2R$   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   connect_graph|   s    $
c         C  s   |  j  | S(   u'   Return the node with the given address.(   R   (   R   t   node_address(    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   get_by_address‰   s    c         C  s   | |  j  k S(   uq   
        Returns true if the graph contains a node with the given node
        address, false otherwise.
        (   R   (   R   R)   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   contains_address   s    c         C  sè   d } | d 7} | d 7} x½ t  |  j j ƒ  d d „  ƒD] } | d | d | d | d f 7} xq | d	 j ƒ  D]_ \ } } xP | D]H } | d k	 r¶ | d
 | d | | f 7} q† | d | d | f 7} q† Wqs Wq9 W| d 7} | S(   u  Return a dot representation suitable for using with Graphviz.

        >>> dg = DependencyGraph(
        ...     'John N 2\n'
        ...     'loves V 0\n'
        ...     'Mary N 2'
        ... )
        >>> print(dg.to_dot())
        digraph G{
        edge [dir=forward]
        node [shape=plaintext]
        <BLANKLINE>
        0 [label="0 (None)"]
        0 -> 2 [label="ROOT"]
        1 [label="1 (John)"]
        2 [label="2 (loves)"]
        2 -> 1 [label=""]
        2 -> 3 [label=""]
        3 [label="3 (Mary)"]
        }

        u   digraph G{
u   edge [dir=forward]
u   node [shape=plaintext]
t   keyc         S  s   |  d S(   Nu   address(    (   t   v(    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyR   ±   t    u   
%s [label="%s (%s)"]u   addressu   wordu   depsu   
%s -> %s [label="%s"]u
   
%s -> %s u   
}N(   t   sortedR   R   t   itemsR	   (   R   t   sR   t   relt   depsR   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   to_dot”   s    

%$
c      
   C  s   |  j  ƒ  } y: t j d d g d t j d t j d t j d t ƒ} Wn t k
 re t d ƒ ‚ n X| j | ƒ \ } } | r™ t d j | ƒ ƒ ‚ n  | S(	   u7  Show SVG representation of the transducer (IPython magic).

        >>> dg = DependencyGraph(
        ...     'John N 2\n'
        ...     'loves V 0\n'
        ...     'Mary N 2'
        ... )
        >>> dg._repr_svg_().split('\n')[0]
        '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'

        u   dotu   -Tsvgt   stdint   stdoutt   stderrt   universal_newlinesu0   Cannot find the dot binary from Graphviz packageu?   Cannot create svg representation by running dot from string: {}(	   R4   t
   subprocesst   Popent   PIPEt   Truet   OSErrort	   Exceptiont   communicatet   format(   R   t
   dot_stringt   processt   outt   err(    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt
   _repr_svg_Á   s     			c         C  s   t  |  j ƒ S(   N(   R   R   (   R   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   __str__á   s    c         C  s   d j  t |  j ƒ ƒ S(   Nu    <DependencyGraph with {0} nodes>(   R@   t   lenR   (   R   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   __repr__ä   s    c         C  sW   t  |  ƒ E } g  | j ƒ  j d ƒ D]$ } t | d | d | d | ƒ^ q% SWd QXd S(   uï  
        :param filename: a name of a file in Malt-TAB format
        :param zero_based: nodes in the input file are numbered starting from 0
        rather than 1 (as produced by, e.g., zpar)
        :param str cell_separator: the cell separator. If not provided, cells
        are split by whitespace.
        :param str top_relation_label: the label by which the top relation is
        identified, for examlple, `ROOT`, `null` or `TOP`.

        :return: a list of DependencyGraphs

        u   

R   R   R   N(   t   opent   readt   splitR   (   t   filenameR   R   R   t   infileR   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   loadç   s    c           sK   t  j |  j | d j ƒ  ƒ } |  j | d ‰  t ‡  f d †  | Dƒ ƒ S(   ul   
        Returns the number of left children under the node specified
        by the given address.
        u   depsu   addressc         3  s!   |  ] } | ˆ  k  r d  Vq d S(   i   N(    (   t   .0t   c(   t   index(    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pys	   <genexpr>	  s    (   R   t   from_iterableR   R   t   sum(   R   t
   node_indext   children(    (   RQ   s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   left_children  s     c           sK   t  j |  j | d j ƒ  ƒ } |  j | d ‰  t ‡  f d †  | Dƒ ƒ S(   um   
        Returns the number of right children under the node specified
        by the given address.
        u   depsu   addressc         3  s!   |  ] } | ˆ  k r d  Vq d S(   i   N(    (   RO   RP   (   RQ   (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pys	   <genexpr>  s    (   R   RR   R   R   RS   (   R   RT   RU   (    (   RQ   s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   right_children  s     c         C  s2   |  j  | d ƒ s. |  j | d j | ƒ n  d  S(   Nu   address(   R+   R   R   (   R   R   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   add_node  s    c      	   C  s½  d „  } d „  } d „  } d „  }	 i | d 6| d 6| d 6|	 d 6}
 t  | t ƒ rq d	 „  | j d
 ƒ Dƒ } n  d „  | Dƒ } d „  | Dƒ } d } xÈt | d d ƒD]´\ } } | j | ƒ } | d k rà t | ƒ } n | t | ƒ k sø t ‚ | d k r>y |
 | } Wq>t k
 r:t d j	 | ƒ ƒ ‚ q>Xn  y+ | | | ƒ \ } } } } } } } } Wn8 t
 t f k
 r£| | ƒ \ } } } } } } } n X| d k r¶qª n  t | ƒ } | rÕ| d 7} n  |  j | j i | d 6| d 6| d 6| d 6| d 6| d 6| d 6| d 6ƒ | d k rB| d k rB| } n  |  j | d | j | ƒ qª W|  j d d | r¬|  j d d | d } |  j | |  _ | |  _ n t j d ƒ d S(   u½  Parse a sentence.

        :param extractor: a function that given a tuple of cells returns a
        7-tuple, where the values are ``word, lemma, ctag, tag, feats, head,
        rel``.

        :param str cell_separator: the cell separator. If not provided, cells
        are split by whitespace.

        :param str top_relation_label: the label by which the top relation is
        identified, for examlple, `ROOT`, `null` or `TOP`.

        c         S  s+   |  \ } } } | | | | | d | d f S(   Nu    (    (   t   cellsRQ   t   wordt   tagt   head(    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   extract_3_cells.  s    c         S  s.   |  \ } } } } | | | | | d | | f S(   Nu    (    (   RY   RQ   RZ   R[   R\   R2   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   extract_4_cells2  s    c   	      S  s[   |  \ } } } } } } } y t  | ƒ } Wn t k
 r> n X| | | | | d | | f S(   Nu    (   t   intt
   ValueError(	   RY   RQ   t
   line_indexRZ   t   lemmaR[   t   _R\   R2   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   extract_7_cells6  s    c      
   S  sd   |  \
 } } } } } } } }	 }
 }
 y t  | ƒ } Wn t k
 rG n X| | | | | | | |	 f S(   N(   R_   R`   (   RY   RQ   Ra   RZ   Rb   t   ctagR[   t   featsR\   R2   Rc   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   extract_10_cells?  s    $i   i   i   i
   c         s  s   |  ] } | Vq d  S(   N(    (   RO   t   line(    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pys	   <genexpr>P  s    u   
c         s  s   |  ] } | j  ƒ  Vq d  S(   N(   t   rstrip(   RO   t   l(    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pys	   <genexpr>R  s    c         s  s   |  ] } | r | Vq d  S(   N(    (   RO   Rj   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pys	   <genexpr>S  s    t   starti   uU   Number of tab-delimited fields ({0}) not supported by CoNLL(10) or Malt-Tab(4) formatu   _u   addressu   wordu   lemmau   ctagu   tagu   featsu   headu   reli    u   depsuB   The graph doesn't contain a node that depends on the root element.N(   t
   isinstanceR   RK   R	   t	   enumerateRG   t   AssertionErrort   KeyErrorR`   R@   t	   TypeErrorR_   R   R   R   R   R   t   warningst   warn(   R   t   input_R   R   R   R   R]   R^   Rd   Rg   t
   extractorst   linest   cell_numberRQ   Rh   RY   RZ   Rb   Re   R[   Rf   R\   R2   t   root_address(    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyR     sn    						
(%	 c         C  s'   | d } | r# | d k r# | Sn  | S(   Nu   wordu   ,(    (   R   R   t   filtert   w(    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   _word’  s
    
c         C  so   |  j  | ƒ } | d } t t j | d j ƒ  ƒ ƒ } | rg t | g  | D] } |  j | ƒ ^ qK ƒ S| Sd S(   u¦    Turn dependency graphs into NLTK trees.

        :param int i: index of a node
        :return: either a word (if the indexed node is a leaf) or a ``Tree``.
        u   wordu   depsN(   R*   R/   R   RR   R   R   t   _tree(   R   t   iR   RZ   R3   R   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyR{   ™  s    
)c         C  s[   |  j  } | d } t t j | d j ƒ  ƒ ƒ } t | g  | D] } |  j | ƒ ^ q? ƒ S(   u–   
        Starting with the ``root`` node, build a dependency tree using the NLTK
        ``Tree`` constructor. Dependency labels are omitted.
        u   wordu   deps(   R   R/   R   RR   R   R   R{   (   R   R   RZ   R3   R   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   tree¨  s    	
c         c  s¥   | s |  j  } n  | d | d f } xx t t j | d j ƒ  ƒ ƒ D]W } |  j | ƒ } | | d | d | d f f Vx |  j d | ƒ D] } | VqŽ WqF Wd S(   us   
        Extract dependency triples of the form:
        ((head word, head tag), rel, (dep word, dep tag))
        u   wordu   ctagu   depsu   relR   N(   R   R/   R   RR   R   R*   t   triples(   R   R   R\   R|   R   t   triple(    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyR~   ³  s    & c         C  s,   y |  j  | d SWn t k
 r' d  SXd  S(   Nu   head(   R   t
   IndexErrorR	   (   R   R|   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   _hdÃ  s    c         C  s,   y |  j  | d SWn t k
 r' d  SXd  S(   Nu   rel(   R   R€   R	   (   R   R|   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   _relÉ  s    c         C  s6  i  } xL |  j  j ƒ  D]; } x2 | d D]& } t | d | g ƒ } d | | <q' Wq WxÚ |  j  D]Ï } i  } xf | D]^ } xU | D]M } | d | d k r t | d | d g ƒ } | | | | | | <q q Wqr WxW | D]O }	 | |	 | |	 <|	 d |	 d k rÛ |  j |  j |	 d ƒ |	 d ƒ }
 |
 SqÛ Wq_ Wt S(   uE  Check whether there are cycles.

        >>> dg = DependencyGraph(treebank_data)
        >>> dg.contains_cycle()
        False

        >>> cyclic_dg = DependencyGraph()
        >>> top = {'word': None, 'deps': [1], 'rel': 'TOP', 'address': 0}
        >>> child1 = {'word': None, 'deps': [2], 'rel': 'NTOP', 'address': 1}
        >>> child2 = {'word': None, 'deps': [4], 'rel': 'NTOP', 'address': 2}
        >>> child3 = {'word': None, 'deps': [1], 'rel': 'NTOP', 'address': 3}
        >>> child4 = {'word': None, 'deps': [3], 'rel': 'NTOP', 'address': 4}
        >>> cyclic_dg.nodes = {
        ...     0: top,
        ...     1: child1,
        ...     2: child2,
        ...     3: child3,
        ...     4: child4,
        ... }
        >>> cyclic_dg.root = top

        >>> cyclic_dg.contains_cycle()
        [3, 1, 2, 4]

        u   depsu   addressi   i    (   R   R   t   tuplet   get_cycle_pathR*   t   False(   R   t	   distancesR   R   R,   Rc   t   new_entriest   pair1t   pair2t   pairt   path(    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   contains_cycleÐ  s$    !#c         C  sŠ   x) | d D] } | | k r | d g Sq WxW | d D]K } |  j  |  j | ƒ | ƒ } t | ƒ d k r7 | j d | d ƒ | Sq7 Wg  S(   Nu   depsu   addressi    (   R„   R*   RG   t   insert(   R   t	   curr_nodet   goal_node_indexR   R‹   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyR„     s    c           s€   | d k r d ‰  n? | d k r* d ‰  n* | d k r? d ‰  n t  d j | ƒ ƒ ‚ d j ‡  f d	 †  t |  j j ƒ  ƒ Dƒ ƒ S(
   u®   
        The dependency graph in CoNLL format.

        :param style: the style to use for the format (3, 4, 10 columns)
        :type style: int
        :rtype: str
        i   u   {word}	{tag}	{head}
i   u   {word}	{tag}	{head}	{rel}
i
   u9   {i}	{word}	{lemma}	{ctag}	{tag}	{feats}	{head}	{rel}	_	_
uU   Number of tab-delimited fields ({0}) not supported by CoNLL(10) or Malt-Tab(4) formatu    c         3  s:   |  ]0 \ } } | d  d k r ˆ  j  d | |  Vq d S(   u   tagu   TOPR|   N(   R@   (   RO   R|   R   (   t   template(    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pys	   <genexpr>%  s   	(   R`   R@   t   joinR/   R   R0   (   R   t   style(    (   R   s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   to_conll  s    				c         C  sÉ   d d l  } t t d t |  j ƒ ƒ ƒ } g  | D]6 } |  j | ƒ r1 | |  j | ƒ |  j | ƒ f ^ q1 } i  |  _ x& | D] } |  j | d |  j | <q} W| j ƒ  } | j	 | ƒ | j
 | ƒ | S(   uJ   Convert the data in a ``nodelist`` into a networkx labeled directed graph.iÿÿÿÿNi   u   word(   t   networkxR
   t   rangeRG   R   R   R‚   t	   nx_labelst   MultiDiGrapht   add_nodes_fromt   add_edges_from(   R   R”   t   nx_nodelistt   nt   nx_edgelistt   g(    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   nx_graph*  s    C	N(!   t   __name__t
   __module__t   __doc__R	   R…   R   R   R    R%   R(   R*   R+   R4   RE   RF   RH   t   staticmethodRN   RV   RW   RX   R   R<   Rz   R{   R}   R~   R   R‚   RŒ   R„   R“   Rž   (    (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyR   #   sF   .			
				-	 							t					2		t   DependencyGraphErrorc           B  s   e  Z d  Z RS(   u   Dependency graph exception.(   RŸ   R    R¡   (    (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyR£   =  s   c           C  s    t  ƒ  t ƒ  t ƒ  t ƒ  d  S(   N(   t	   malt_demot
   conll_demot   conll_file_demot   cycle_finding_demo(    (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   demoA  s    c         C  sÓ   t  d ƒ } | j ƒ  } | j ƒ  |  rÏ d d l } d d l m } | j ƒ  } | j ƒ  | j | d d ƒ} | j	 | | d d ƒ| j
 | | | j ƒ | j g  ƒ | j g  ƒ | j d	 ƒ | j ƒ  n  d S(
   uw   
    A demonstration of the result of reading a dependency
    version of the first sentence of the Penn Treebank.
    u  Pierre  NNP     2       NMOD
Vinken  NNP     8       SUB
,       ,       2       P
61      CD      5       NMOD
years   NNS     6       AMOD
old     JJ      2       NMOD
,       ,       2       P
will    MD      0       ROOT
join    VB      8       VC
the     DT      11      NMOD
board   NN      9       OBJ
as      IN      9       VMOD
a       DT      15      NMOD
nonexecutive    JJ      15      NMOD
director        NN      12      PMOD
Nov.    NNP     9       VMOD
29      CD      16      NMOD
.       .       9       VMOD
iÿÿÿÿN(   t   pylabt   dimi   t	   node_sizei2   u   tree.png(   R   R}   t   pprintR”   t
   matplotlibR©   Rž   t   infot   spring_layoutt   draw_networkx_nodest   draw_networkx_labelsR–   t   xtickst   ytickst   savefigt   show(   t   nxt   dgR}   R”   R©   R   t   pos(    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyR¤   H  s     	

c          C  sC   t  t ƒ }  |  j ƒ  } | j ƒ  t |  ƒ t |  j d ƒ ƒ d S(   ug   
    A demonstration of how to read a string representation of
    a CoNLL format dependency tree.
    i   N(   R   t   conll_data1R}   R¬   t   printR“   (   R·   R}   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyR¥   u  s
    

c          C  sm   t  d ƒ g  t j d ƒ D] }  |  r t |  ƒ ^ q } x. | D]& } | j ƒ  } t  d ƒ | j ƒ  q? Wd  S(   Nu   Mass conll_read demo...u   

u   
(   Rº   t   conll_data2RK   R   R}   R¬   (   t   entryt   graphst   graphR}   (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyR¦     s    
.
c          C  s  t  t ƒ }  t |  j ƒ  ƒ t  ƒ  } | j i d  d 6d g d 6d d 6d d 6ƒ | j i d  d 6d g d 6d	 d 6d d 6ƒ | j i d  d 6d
 g d 6d	 d 6d d 6ƒ | j i d  d 6d g d 6d	 d 6d d 6ƒ | j i d  d 6d g d 6d	 d 6d
 d 6ƒ t | j ƒ  ƒ d  S(   Nu   wordi   u   depsu   TOPu   reli    u   addressi   u   NTOPi   i   (   R   t   treebank_dataRº   RŒ   RX   R	   (   R·   t	   cyclic_dg(    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyR§   Š  s    	,,,,,u  Pierre  NNP     2       NMOD
Vinken  NNP     8       SUB
,       ,       2       P
61      CD      5       NMOD
years   NNS     6       AMOD
old     JJ      2       NMOD
,       ,       2       P
will    MD      0       ROOT
join    VB      8       VC
the     DT      11      NMOD
board   NN      9       OBJ
as      IN      9       VMOD
a       DT      15      NMOD
nonexecutive    JJ      15      NMOD
director        NN      12      PMOD
Nov.    NNP     9       VMOD
29      CD      16      NMOD
.       .       9       VMOD
u/  
1   Ze                ze                Pron  Pron  per|3|evofmv|nom                 2   su      _  _
2   had               heb               V     V     trans|ovt|1of2of3|ev             0   ROOT    _  _
3   met               met               Prep  Prep  voor                             8   mod     _  _
4   haar              haar              Pron  Pron  bez|3|ev|neut|attr               5   det     _  _
5   moeder            moeder            N     N     soort|ev|neut                    3   obj1    _  _
6   kunnen            kan               V     V     hulp|ott|1of2of3|mv              2   vc      _  _
7   gaan              ga                V     V     hulp|inf                         6   vc      _  _
8   winkelen          winkel            V     V     intrans|inf                      11  cnj     _  _
9   ,                 ,                 Punc  Punc  komma                            8   punct   _  _
10  zwemmen           zwem              V     V     intrans|inf                      11  cnj     _  _
11  of                of                Conj  Conj  neven                            7   vc      _  _
12  terrassen         terras            N     N     soort|mv|neut                    11  cnj     _  _
13  .                 .                 Punc  Punc  punt                             12  punct   _  _
u  1   Cathy             Cathy             N     N     eigen|ev|neut                    2   su      _  _
2   zag               zie               V     V     trans|ovt|1of2of3|ev             0   ROOT    _  _
3   hen               hen               Pron  Pron  per|3|mv|datofacc                2   obj1    _  _
4   wild              wild              Adj   Adj   attr|stell|onverv                5   mod     _  _
5   zwaaien           zwaai             N     N     soort|mv|neut                    2   vc      _  _
6   .                 .                 Punc  Punc  punt                             5   punct   _  _

1   Ze                ze                Pron  Pron  per|3|evofmv|nom                 2   su      _  _
2   had               heb               V     V     trans|ovt|1of2of3|ev             0   ROOT    _  _
3   met               met               Prep  Prep  voor                             8   mod     _  _
4   haar              haar              Pron  Pron  bez|3|ev|neut|attr               5   det     _  _
5   moeder            moeder            N     N     soort|ev|neut                    3   obj1    _  _
6   kunnen            kan               V     V     hulp|ott|1of2of3|mv              2   vc      _  _
7   gaan              ga                V     V     hulp|inf                         6   vc      _  _
8   winkelen          winkel            V     V     intrans|inf                      11  cnj     _  _
9   ,                 ,                 Punc  Punc  komma                            8   punct   _  _
10  zwemmen           zwem              V     V     intrans|inf                      11  cnj     _  _
11  of                of                Conj  Conj  neven                            7   vc      _  _
12  terrassen         terras            N     N     soort|mv|neut                    11  cnj     _  _
13  .                 .                 Punc  Punc  punt                             12  punct   _  _

1   Dat               dat               Pron  Pron  aanw|neut|attr                   2   det     _  _
2   werkwoord         werkwoord         N     N     soort|ev|neut                    6   obj1    _  _
3   had               heb               V     V     hulp|ovt|1of2of3|ev              0   ROOT    _  _
4   ze                ze                Pron  Pron  per|3|evofmv|nom                 6   su      _  _
5   zelf              zelf              Pron  Pron  aanw|neut|attr|wzelf             3   predm   _  _
6   uitgevonden       vind              V     V     trans|verldw|onverv              3   vc      _  _
7   .                 .                 Punc  Punc  punt                             6   punct   _  _

1   Het               het               Pron  Pron  onbep|neut|zelfst                2   su      _  _
2   hoorde            hoor              V     V     trans|ovt|1of2of3|ev             0   ROOT    _  _
3   bij               bij               Prep  Prep  voor                             2   ld      _  _
4   de                de                Art   Art   bep|zijdofmv|neut                6   det     _  _
5   warme             warm              Adj   Adj   attr|stell|vervneut              6   mod     _  _
6   zomerdag          zomerdag          N     N     soort|ev|neut                    3   obj1    _  _
7   die               die               Pron  Pron  betr|neut|zelfst                 6   mod     _  _
8   ze                ze                Pron  Pron  per|3|evofmv|nom                 12  su      _  _
9   ginds             ginds             Adv   Adv   gew|aanw                         12  mod     _  _
10  achter            achter            Adv   Adv   gew|geenfunc|stell|onverv        12  svp     _  _
11  had               heb               V     V     hulp|ovt|1of2of3|ev              7   body    _  _
12  gelaten           laat              V     V     trans|verldw|onverv              11  vc      _  _
13  .                 .                 Punc  Punc  punt                             12  punct   _  _

1   Ze                ze                Pron  Pron  per|3|evofmv|nom                 2   su      _  _
2   hadden            heb               V     V     trans|ovt|1of2of3|mv             0   ROOT    _  _
3   languit           languit           Adv   Adv   gew|geenfunc|stell|onverv        11  mod     _  _
4   naast             naast             Prep  Prep  voor                             11  mod     _  _
5   elkaar            elkaar            Pron  Pron  rec|neut                         4   obj1    _  _
6   op                op                Prep  Prep  voor                             11  ld      _  _
7   de                de                Art   Art   bep|zijdofmv|neut                8   det     _  _
8   strandstoelen     strandstoel       N     N     soort|mv|neut                    6   obj1    _  _
9   kunnen            kan               V     V     hulp|inf                         2   vc      _  _
10  gaan              ga                V     V     hulp|inf                         9   vc      _  _
11  liggen            lig               V     V     intrans|inf                      10  vc      _  _
12  .                 .                 Punc  Punc  punt                             11  punct   _  _

1   Zij               zij               Pron  Pron  per|3|evofmv|nom                 2   su      _  _
2   zou               zal               V     V     hulp|ovt|1of2of3|ev              7   cnj     _  _
3   mams              mams              N     N     soort|ev|neut                    4   det     _  _
4   rug               rug               N     N     soort|ev|neut                    5   obj1    _  _
5   ingewreven        wrijf             V     V     trans|verldw|onverv              6   vc      _  _
6   hebben            heb               V     V     hulp|inf                         2   vc      _  _
7   en                en                Conj  Conj  neven                            0   ROOT    _  _
8   mam               mam               V     V     trans|ovt|1of2of3|ev             7   cnj     _  _
9   de                de                Art   Art   bep|zijdofmv|neut                10  det     _  _
10  hare              hare              Pron  Pron  bez|3|ev|neut|attr               8   obj1    _  _
11  .                 .                 Punc  Punc  punt                             10  punct   _  _

1   Of                of                Conj  Conj  onder|metfin                     0   ROOT    _  _
2   ze                ze                Pron  Pron  per|3|evofmv|nom                 3   su      _  _
3   had               heb               V     V     hulp|ovt|1of2of3|ev              0   ROOT    _  _
4   gewoon            gewoon            Adj   Adj   adv|stell|onverv                 10  mod     _  _
5   met               met               Prep  Prep  voor                             10  mod     _  _
6   haar              haar              Pron  Pron  bez|3|ev|neut|attr               7   det     _  _
7   vriendinnen       vriendin          N     N     soort|mv|neut                    5   obj1    _  _
8   rond              rond              Adv   Adv   deelv                            10  svp     _  _
9   kunnen            kan               V     V     hulp|inf                         3   vc      _  _
10  slenteren         slenter           V     V     intrans|inf                      9   vc      _  _
11  in                in                Prep  Prep  voor                             10  mod     _  _
12  de                de                Art   Art   bep|zijdofmv|neut                13  det     _  _
13  buurt             buurt             N     N     soort|ev|neut                    11  obj1    _  _
14  van               van               Prep  Prep  voor                             13  mod     _  _
15  Trafalgar_Square  Trafalgar_Square  MWU   N_N   eigen|ev|neut_eigen|ev|neut      14  obj1    _  _
16  .                 .                 Punc  Punc  punt                             15  punct   _  _
u   __main__(    R¡   t
   __future__R    R   t   collectionsR   t	   itertoolsR   R¬   R   R9   Rq   t   sixR   t	   nltk.treeR   t   nltk.compatR   t   objectR   R>   R£   R¨   R…   R¤   R¥   R¦   R§   R¿   R¹   R»   RŸ   (    (    (    s9   lib/python2.7/site-packages/nltk/parse/dependencygraph.pyt   <module>   s0   ÿ ÿ 	-				V