o
    i+                     @   s&  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
 d dlmZ d dlmZ d d	lmZ d d
lmZ e jdd Ze jdd Ze jdd Ze jdd Ze jdd Ze jdd Ze jdd Zdd Zdd Zdd Zdd  Ze jj d!d"d#d$ Z!e jj d!d"d%d& Z"dS )'    N)Model)registry)ArcEager)DEFAULT_PARSER_MODEL)DEFAULT_TOK2VEC_MODEL)ParserDoc)ExampleVocabc                   C   s   t  S Nr    r   r   Y/home/ubuntu/.local/lib/python3.10/site-packages/spacy/tests/parser/test_neural_parser.pyvocab   s   r   c                 C   s   t jdgdgd}t | j|S )NLR)left_labelsright_labels)r   get_actionsstrings)r   actionsr   r   r   	arc_eager   s   r   c                  C   s&   dt i} tj| ddd }|  |S )NmodelTvalidate)r   r   resolve
initialize)cfgtok2vecr   r   r   r      s   r   c                 C   s<   dddd}dt i}tj|ddd }t| |fd|i|S )	NF   d   learn_tokensmin_action_frequpdate_with_oracle_cut_sizer   Tr   moves)r   r   r   r   )r   r   configr   r   r   r   r   parser!   s   r(   c                 C   s8   dt i}tj|ddd }|jd || j |  |S )Nr   Tr   resize_output)r   r   r   attrsn_movesr   )r   r   r   r   r   r   r   r   r   -   s
   r   c                 C   s   t | g ddS )N)abc)wordsr   )r   r   r   r   doc6   s   r0   c                 C   s   g dg ddS )N)   r1   r1   )r   ROOTr   )headsdepsr   )r0   r   r   r   gold;   s   r5   c                 C   s   t | jtsJ d S r   )
isinstancer   r   )r(   r   r   r   test_can_init_nn_parser@   s   r7   c                 C   sT   dddd}dt i}tj|ddd }t|f|| jd|j| _| jd us(J d S )	NFr   r!   r"   r   Tr   )r   r&   )r   r   r   r   r&   r   )r(   r   r'   r   r   r   r   r   test_build_modelD   s   r8   c                 C   s$   | |gd |_|| _| | d S )Nr   )predicttensorr   )r(   r   r   r0   r   r   r   test_predict_docP   s   r;   c                 C   s.   || _ dd }t||}| j|g|d d S )Nc                 S   s   |d| 8 }||fS NMbP?r   )keyweightsgradientr   r   r   optimizeY   s   z!test_update_doc.<locals>.optimizesgd)r   r
   	from_dictupdate)r(   r   r0   r5   rA   exampler   r   r   test_update_docV   s   rG   zNo longer supported)reasonc                 C   s   || _ | |ddd d S )N    r=   )
beam_widthbeam_density)r   )r(   r   r0   r   r   r   test_predict_doc_beama   s   rL   c                 C   s&   || _ ddd}| j||f|d d S )Nc                 S   s   | d| 8 } d S r<   r   )r?   r@   r>   r   r   r   rA   k   s   z&test_update_doc_beam.<locals>.optimizerB   r   )r   update_beam)r(   r   r0   r5   rA   r   r   r   test_update_doc_beamg   s   
rN   )#pytest	thinc.apir   spacyr   *spacy.pipeline._parser_internals.arc_eagerr   spacy.pipeline.dep_parserr   spacy.pipeline.tok2vecr    spacy.pipeline.transition_parserr   spacy.tokens.docr	   spacy.trainingr
   spacy.vocabr   fixturer   r   r   r(   r   r0   r5   r7   r8   r;   rG   markskiprL   rN   r   r   r   r   <module>   s@    







