o
    i4                     @   st   d dl mZmZmZ ddlmZ ddlmZmZ ddl	m
Z
mZ dee
ef deeeeef  fdd	Zd	eiZd
S )    )IteratorTupleUnion   )Errors)NOUNPRON)DocSpandoclikereturnc                 #   sD   | j   dsttj dsttj fdddD  fdddD } jjd}d	}t	t
d
d | D ]c\}}|jtkrt
 fdd|j}t|d}|durYq<t
fdd|j}dd |D |jg }	t|	}
|
|krt|	d }|
||fV  q<|jtkr|j|v r|j}
|
|kr|jd }|
||fV  q<dS )z
    Detect base noun phrases from a dependency parse. Works on Doc and Span.
    The definition is inspired by https://www.nltk.org/book/ch07.html
    Consider : [Noun + determinant / adjective] and also [Pronoun]
    POSDEPc                       g | ]} j j| qS  vocabstrings.0labeldocr   R/home/ubuntu/.local/lib/python3.10/site-packages/spacy/lang/nl/syntax_iterators.py
<listcomp>   s    znoun_chunks.<locals>.<listcomp>)amodz	nmod:possdetzdet:possc                    r   r   r   r   r   r   r   r   %   s    )nsubjz
nsubj:passNPc                 S   s   | j ttfv S N)posr   r   xr   r   r   <lambda>,   s    znoun_chunks.<locals>.<lambda>c                    s   | j  jjd kS )Nr   )depr   r   r"   r   r   r   r$   3       Nc                    s
   | j  v S r    )r%   r"   )	noun_depsr   r   r$   :   s   
 c                 S   s   g | ]}|j qS r   )i)r   cr   r   r   r   ;   r&      )r   has_annotation
ValueErrorr   E1019E029r   r   add	enumeratefilterr!   r   childrennextr(   minmaxr   r%   )r   pronoun_deps
span_labelend_spanr(   wordnsubjs	next_wordr2   
children_i
start_spanr   )r   r'   r   noun_chunks   sF   	









r>   N)typingr   r   r   errorsr   symbolsr   r   tokensr	   r
   intr>   SYNTAX_ITERATORSr   r   r   r   <module>   s    (C