a
     ˜ëjµ{  ã                   @   sÀ   d Z ddlZddl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 G dd	„ d	ƒZddd„ZG dd„ deƒZdd„ Zddd„Zdd„ Zdd„ Zdd„ ZdZdZdZedkr¼eƒ  dS ) z™
Tools for reading and writing dependency trees.
The input is assumed to be in Malt-TAB format
(https://stp.lingfil.uu.se/~nivre/research/MaltXML.html).
é    N)Údefaultdict)Úchain)Úpformat)Úfind_binary)ÚTreec                   @   sî   e Zd ZdZd:dd„Zdd„ Zd	d
„ Zdd„ Zdd„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zed;dd„ƒZdd„ Zdd „ Zd!d"„ Zd<d#d$„Zd=d&d'„Zd(d)„ Zd*d+„ Zd>d,d-„Zd.d/„ Zd0d1„ Zd2d3„ Zd4d5„ Zd6d7„ Zd8d9„ ZdS )?ÚDependencyGraphzQ
    A container for the nodes and labelled edges of a dependency structure.
    NFÚROOTc                 C   sH   t dd„ ƒ| _| jd  ddddœ¡ d| _|rD| j|||||d� dS )a¬  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   s   d d d d d d d t tƒd dœ	S )N)	ÚaddressÚwordÚlemmaÚctagÚtagÚfeatsÚheadÚdepsÚrel)r   Úlist© r   r   úY/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/nltk/parse/dependencygraph.pyÚ<lambda>=   s    ÷z*DependencyGraph.__init__.<locals>.<lambda>r   ÚTOP)r   r   r	   N)Úcell_extractorÚ
zero_basedÚcell_separatorÚtop_relation_label)r   ÚnodesÚupdateÚrootÚ_parse)ÚselfÚtree_strr   r   r   r   r   r   r   Ú__init__$   s    ÿûzDependencyGraph.__init__c                 C   s   | j |= dS )zw
        Removes the node with the given address.  References
        to this node in others will still exist.
        N©r   )r   r	   r   r   r   Úremove_by_addressW   s    z!DependencyGraph.remove_by_addressc                 C   sL   | j  ¡ D ]<}g }|d D ]"}||v r2| |¡ q| |¡ q||d< q
dS )zp
        Redirects arcs to any of the nodes in the originals list
        to the redirect node address.
        r   N)r   ÚvaluesÚappend)r   Z	originalsÚredirectÚnodeZnew_depsÚdepr   r   r   Úredirect_arcs^   s    zDependencyGraph.redirect_arcsc                 C   s@   | j | d }| j | d  |g ¡ | j | d |  |¡ dS )zw
        Adds an arc from the node specified by head_address to the
        node specified by the mod address.
        r   r   N)r   Ú
setdefaultr%   )r   Zhead_addressZmod_addressÚrelationr   r   r   Úadd_arcl   s    zDependencyGraph.add_arcc                 C   sn   | j  ¡ D ]^}| j  ¡ D ]N}|d |d kr|d dkr|d }|d  |g ¡ |d |  |d ¡ qq
dS )zr
        Fully connects all non-root nodes.  All nodes are set to be dependents
        of the root node.
        r	   r   r   r   N)r   r$   r*   r%   )r   Únode1Únode2r+   r   r   r   Úconnect_graphv   s    zDependencyGraph.connect_graphc                 C   s
   | j | S )z'Return the node with the given address.r"   ©r   Znode_addressr   r   r   Úget_by_addressƒ   s    zDependencyGraph.get_by_addressc                 C   s
   || j v S )zq
        Returns true if the graph contains a node with the given node
        address, false otherwise.
        r"   r0   r   r   r   Úcontains_address‡   s    z DependencyGraph.contains_addressc              	   C   s®   d}|d7 }|d7 }t | j ¡ dd„ d�D ]v}|d |d |d |d	 ¡7 }|d
  ¡ D ]F\}}|D ]8}|durˆ|d |d ||¡7 }qd|d |d |¡7 }qdqXq*|d7 }|S )a  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)"]
        }

        zdigraph G{
zedge [dir=forward]
znode [shape=plaintext]
c                 S   s   | d S ©Nr	   r   )Úvr   r   r   r   «   ó    z(DependencyGraph.to_dot.<locals>.<lambda>)Úkeyz
{} [label="{} ({})"]r	   r
   r   Nz
{} -> {} [label="{}"]z

{} -> {} z
})Úsortedr   r$   ÚformatÚitems)r   Úsr'   r   r   r(   r   r   r   Úto_dotŽ   s     ýzDependencyGraph.to_dotc                 C   s   |   ¡ }t|ƒS )a�  Show SVG representation of the transducer (IPython magic).
        >>> from nltk.test.setup_fixt import check_binary
        >>> check_binary('dot')
        >>> 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"?>'

        )r;   Údot2img)r   Ú
dot_stringr   r   r   Ú
_repr_svg_»   s    zDependencyGraph._repr_svg_c                 C   s
   t | jƒS ©N)r   r   ©r   r   r   r   Ú__str__Ë   s    zDependencyGraph.__str__c                 C   s   dt | jƒ› d�S )Nz<DependencyGraph with z nodes>)Úlenr   r@   r   r   r   Ú__repr__Î   s    zDependencyGraph.__repr__c                    sL   t | ƒ�0}‡ ‡‡fdd„| ¡  d¡D ƒW  d  ƒ S 1 s>0    Y  dS )aû  
        :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

        c                    s   g | ]}t |ˆˆ ˆd �‘qS ))r   r   r   ©r   )Ú.0r    ©r   r   r   r   r   Ú
<listcomp>â   s   úüz(DependencyGraph.load.<locals>.<listcomp>ú

N)ÚopenÚreadÚsplit)Úfilenamer   r   r   Úinfiler   rF   r   ÚloadÑ   s    
ùzDependencyGraph.loadc                    s<   t  | j| d  ¡ ¡}| j| d ‰ t‡ fdd„|D ƒƒS )zl
        Returns the number of left children under the node specified
        by the given address.
        r   r	   c                 3   s   | ]}|ˆ k rd V  qdS ©é   Nr   ©rE   Úc©Úindexr   r   Ú	<genexpr>ó   r5   z0DependencyGraph.left_children.<locals>.<genexpr>©r   Úfrom_iterabler   r$   Úsum©r   Z
node_indexÚchildrenr   rS   r   Úleft_childrenì   s    zDependencyGraph.left_childrenc                    s<   t  | j| d  ¡ ¡}| j| d ‰ t‡ fdd„|D ƒƒS )zm
        Returns the number of right children under the node specified
        by the given address.
        r   r	   c                 3   s   | ]}|ˆ krd V  qdS rO   r   rQ   rS   r   r   rU   ü   r5   z1DependencyGraph.right_children.<locals>.<genexpr>rV   rY   r   rS   r   Úright_childrenõ   s    zDependencyGraph.right_childrenc                 C   s&   |   |d ¡s"| j|d   |¡ d S r3   )r2   r   r   )r   r'   r   r   r   Úadd_nodeþ   s    zDependencyGraph.add_nodec                 C   s  dd„ }dd„ }dd„ }dd„ }	||||	d	œ}
t |tƒrLd
d„ | d¡D ƒ}dd„ |D ƒ}dd„ |D ƒ}d}t|dd�D �]@\}}| |¡}|du ržt|ƒ}n|t|ƒks®J ‚|du røz|
| }W n4 työ } ztd |¡ƒ|‚W Y d}~n
d}~0 0 z|||ƒ\}}}}}}}}W n. ttf�yD   ||ƒ\}}}}}}}Y n0 |dk�rRqxt	|ƒ}|�rh|d7 }| j
|  ||||||||dœ¡ |dk�r¢|dk�r¢|}| j
| d |  |¡ qx| j
d d | �rú| j
d d | d }| j
| | _|| _n
t d¡ dS )a½  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 ©NÚ r   )ÚcellsrT   r
   r   r   r   r   r   Úextract_3_cells  s    
z/DependencyGraph._parse.<locals>.extract_3_cellsc                 S   s    | \}}}}|||||d||fS r^   r   )r`   rT   r
   r   r   r   r   r   r   Úextract_4_cells  s    z/DependencyGraph._parse.<locals>.extract_4_cellsc           	      S   sF   | \}}}}}}}zt |ƒ}W n ty0   Y n0 |||||d||fS r^   ©ÚintÚ
ValueError)	r`   rT   Ú
line_indexr
   r   r   Ú_r   r   r   r   r   Úextract_7_cells   s    z/DependencyGraph._parse.<locals>.extract_7_cellsc              
   S   sL   | \
}}}}}}}}	}
}
zt |ƒ}W n ty6   Y n0 ||||||||	fS r?   rc   )r`   rT   rf   r
   r   r   r   r   r   r   rg   r   r   r   Úextract_10_cells)  s    z0DependencyGraph._parse.<locals>.extract_10_cells)é   é   é   é
   c                 s   s   | ]
}|V  qd S r?   r   )rE   Úliner   r   r   rU   :  r5   z)DependencyGraph._parse.<locals>.<genexpr>Ú
c                 s   s   | ]}|  ¡ V  qd S r?   )Úrstrip©rE   Úlr   r   r   rU   <  r5   c                 s   s   | ]}|r|V  qd S r?   r   rq   r   r   r   rU   =  r5   NrP   )ÚstartúTNumber of tab-delimited fields ({}) not supported by CoNLL(10) or Malt-Tab(4) formatrg   )r	   r
   r   r   r   r   r   r   rj   r   r   zBThe graph doesn't contain a node that depends on the root element.)Ú
isinstanceÚstrrK   Ú	enumeraterB   ÚKeyErrorre   r8   Ú	TypeErrorrd   r   r   r%   r   r   ÚwarningsÚwarn)r   Zinput_r   r   r   r   ra   rb   rh   ri   Z
extractorsÚlinesZcell_numberrT   rn   r`   Úer
   r   r   r   r   r   r   Zroot_addressr   r   r   r     s|    	
ü


ÿÿýÿ

øÿÿzDependencyGraph._parseTc                 C   s   |d }|r|dkr|S |S )Nr
   ú,r   )r   r'   ÚfilterÚwr   r   r   Ú_word|  s
    zDependencyGraph._wordc                    sL   ˆ   |¡}|d }tt |d  ¡ ¡ƒ}|rDt|‡ fdd„|D ƒƒS |S dS )z¥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``.
        r
   r   c                    s   g | ]}ˆ   |¡‘qS r   ©Ú_tree©rE   r(   r@   r   r   rG   Ž  r5   z)DependencyGraph._tree.<locals>.<listcomp>N)r1   r7   r   rW   r$   r   )r   Úir'   r
   r   r   r@   r   rƒ   ƒ  s    
zDependencyGraph._treec                    s<   ˆ j }|d }tt |d  ¡ ¡ƒ}t|‡ fdd„|D ƒƒS )z–
        Starting with the ``root`` node, build a dependency tree using the NLTK
        ``Tree`` constructor. Dependency labels are omitted.
        r
   r   c                    s   g | ]}ˆ   |¡‘qS r   r‚   r„   r@   r   r   rG   ›  r5   z(DependencyGraph.tree.<locals>.<listcomp>)r   r7   r   rW   r$   r   )r   r'   r
   r   r   r@   r   Útree’  s    zDependencyGraph.treec                 c   sr   |s
| j }|d |d f}tt |d  ¡ ¡ƒD ]<}|  |¡}||d |d |d ffV  | j|d�E dH  q0dS )zs
        Extract dependency triples of the form:
        ((head word, head tag), rel, (dep word, dep tag))
        r
   r   r   r   )r'   N)r   r7   r   rW   r$   r1   Útriples)r   r'   r   r…   r(   r   r   r   r‡   �  s    
zDependencyGraph.triplesc                 C   s*   z| j | d W S  ty$   Y d S 0 d S )Nr   ©r   Ú
IndexError©r   r…   r   r   r   Ú_hd¬  s    zDependencyGraph._hdc                 C   s*   z| j | d W S  ty$   Y d S 0 d S )Nr   rˆ   rŠ   r   r   r   Ú_rel²  s    zDependencyGraph._relc                 C   sæ   i }| j  ¡ D ]*}|d D ]}t|d |gƒ}d||< qq| j D ] }i }|D ]F}|D ]<}|d |d krTt|d |d gƒ}|| ||  ||< qTqL|D ]F}	||	 ||	< |	d |	d kr˜|  |  |	d ¡|	d ¡}
|
    S q˜q@dS )aE  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()
        [1, 2, 4, 3]

        r   r	   rP   r   F)r   r$   ÚtupleÚget_cycle_pathr1   )r   Z	distancesr'   r(   r6   rg   Znew_entriesZpair1Zpair2ÚpairÚpathr   r   r   Úcontains_cycle¹  s$    
zDependencyGraph.contains_cyclec                 C   sl   |d D ]}||kr|d g  S q|d D ]:}|   |  |¡|¡}t|ƒdkr,| d|d ¡ |  S q,g S )Nr   r	   r   )rŽ   r1   rB   Úinsert)r   Z	curr_nodeZgoal_node_indexr(   r�   r   r   r   rŽ   ë  s    
zDependencyGraph.get_cycle_pathc                    sZ   |dkrd‰ n*|dkrd‰ n|dkr*d‰ nt d |¡ƒ‚d ‡ fd	d
„t| j ¡ ƒD ƒ¡S )z®
        The dependency graph in CoNLL format.

        :param style: the style to use for the format (3, 4, 10 columns)
        :type style: int
        :rtype: str
        rj   z{word}	{tag}	{head}
rk   z{word}	{tag}	{head}	{rel}
rm   z9{i}	{word}	{lemma}	{ctag}	{tag}	{feats}	{head}	{rel}	_	_
rt   r_   c                 3   s2   | ]*\}}|d  dkrˆ j f d|i|¤ŽV  qdS )r   r   r…   N)r8   )rE   r…   r'   ©Útemplater   r   rU     s   þz+DependencyGraph.to_conll.<locals>.<genexpr>)re   r8   Újoinr7   r   r9   )r   Ústyler   r“   r   Úto_conllö  s    	ÿÿÿþzDependencyGraph.to_conllc                    sr   ddl }ttdtˆ jƒƒƒ}‡ fdd„|D ƒ}i ˆ _|D ]}ˆ j| d ˆ j|< q8| ¡ }| |¡ | |¡ |S )zJConvert the data in a ``nodelist`` into a networkx labeled directed graph.r   NrP   c                    s,   g | ]$}ˆ   |¡r|ˆ   |¡ˆ  |¡f‘qS r   )r‹   rŒ   )rE   Únr@   r   r   rG     s   z,DependencyGraph.nx_graph.<locals>.<listcomp>r
   )	Únetworkxr   ÚrangerB   r   Ú	nx_labelsZMultiDiGraphZadd_nodes_fromZadd_edges_from)r   r™   Znx_nodelistZnx_edgelistr˜   Úgr   r@   r   Únx_graph  s    
ÿ

zDependencyGraph.nx_graph)NNFNr   )FNr   )NFNr   )T)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r!   r#   r)   r,   r/   r1   r2   r;   r>   rA   rC   ÚstaticmethodrN   r[   r\   r]   r   r�   rƒ   r†   r‡   r‹   rŒ   r‘   rŽ   r—   r�   r   r   r   r   r      sL        ú
3
- ÿ		    ú
z

2r   Úsvgc              
   C   s¨   ztt dƒ zL|dv r0tjdd| gd| dd�}ntjdd| gt| dd�d�}|jW W S    td	 | ¡ƒ‚Y n0 W n. ty¢ } ztd
ƒ|‚W Y d}~n
d}~0 0 dS )a­  
    Create image representation fom dot_string, using the 'dot' program
    from the Graphviz package.

    Use the 't' argument to specify the image file format, for ex. 'jpeg', 'eps',
    'json', 'png' or 'webp' (Running 'dot -T:' lists all available formats).

    Note that the "capture_output" option of subprocess.run() is only available
    with text formats (like svg), but not with binary image formats (like png).
    Údot)r¤   Zdot_jsonÚjsonr£   z-T%sT)Úcapture_outputÚinputÚtextÚutf8)Úencoding)r§   zACannot create image representation by running dot from string: {}z0Cannot find the dot binary from Graphviz packageN)r   Ú
subprocessÚrunÚbytesÚstdoutÚ	Exceptionr8   ÚOSError)r=   ÚtÚprocr}   r   r   r   r<   &  s.    
ü

þ
ÿÿr<   c                   @   s   e Zd ZdZdS )ÚDependencyGraphErrorzDependency graph exception.N)rž   rŸ   r    r¡   r   r   r   r   r³   K  s   r³   c                   C   s   t ƒ  tƒ  tƒ  tƒ  d S r?   )Ú	malt_demoÚ
conll_demoÚconll_file_demoÚcycle_finding_demor   r   r   r   ÚdemoO  s    r¸   Fc                 C   s˜   t dƒ}| ¡ }| ¡  | r”ddl}ddlm} | ¡ }| ¡  |j|dd�}|j	||dd� | 
|||j¡ | g ¡ | g ¡ | d	¡ | ¡  dS )
zw
    A demonstration of the result of reading a dependency
    version of the first sentence of the Penn Treebank.
    á  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
r   N)ÚpylabrP   )Zdimé2   )Z	node_sizeztree.png)r   r†   Úpprintr™   Z
matplotlibrº   r�   ÚinfoZspring_layoutZdraw_networkx_nodesZdraw_networkx_labelsr›   ZxticksZyticksZsavefigÚshow)ZnxÚdgr†   r™   rº   rœ   Úposr   r   r   r´   V  s"    ÿ


r´   c                  C   s2   t tƒ} |  ¡ }| ¡  t| ƒ t|  d¡ƒ dS )zg
    A demonstration of how to read a string representation of
    a CoNLL format dependency tree.
    rk   N)r   Úconll_data1r†   r¼   Úprintr—   )r¿   r†   r   r   r   rµ   ƒ  s
    rµ   c                  C   sB   t dƒ dd„ t d¡D ƒ} | D ]}| ¡ }t dƒ | ¡  q d S )NzMass conll_read demo...c                 S   s   g | ]}|rt |ƒ‘qS r   rD   )rE   Úentryr   r   r   rG   ‘  r5   z#conll_file_demo.<locals>.<listcomp>rH   ro   )rÂ   Úconll_data2rK   r†   r¼   )ZgraphsÚgraphr†   r   r   r   r¶   �  s    r¶   c                  C   s˜   t tƒ} t|  ¡ ƒ t ƒ }| d dgdddœ¡ | d dgdddœ¡ | d dgdddœ¡ | d dgdddœ¡ | d dgdddœ¡ t| ¡ ƒ d S )	NrP   r   r   )r
   r   r   r	   é   ZNTOPrk   rj   )r   Útreebank_datarÂ   r‘   r]   )r¿   Z	cyclic_dgr   r   r   r·   ˜  s    r·   r¹   a/  
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   _  _
a  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   _  _
Ú__main__)r£   )F)r¡   r«   rz   Úcollectionsr   Ú	itertoolsr   r¼   r   Znltk.internalsr   Z	nltk.treer   r   r<   r¯   r³   r¸   r´   rµ   r¶   r·   rÇ   rÁ   rÄ   rž   r   r   r   r   Ú<module>   s0       
%
-	V