B
    .(b1                 @   sD   d dl mZ d dlmZ d dlmZ ddlmZ dd Zdd	 Z	d
S )    )unicode_literals)English)EntityRuler   )make_tempdirc           	   C   s   d} t  }t|dd}ddddg}|| || || }dd	 |jD }t  }t &}|d
 }|| t||}	W dQ R X ||	 || }
dd	 |
jD }||kstdS )zTest that the EntityRuler PhraseMatcher is deserialize correctly using
    the method from_disk when the EntityRuler argument phrase_matcher_attr is
    specified.
    z!Spacy is a python library for nlpZLOWER)Zphrase_matcher_attr
PYTHON_LIBspacyspaCy)labelpatternidc             S   s   g | ]}|j |j|jfqS  )textlabel_ent_id_).0entr   r   T/home/dcms/DCMS/lib/python3.7/site-packages/spacy/tests/regression/test_issue4651.py
<listcomp>   s    z;test_issue4651_with_phrase_matcher_attr.<locals>.<listcomp>entityrulerNc             S   s   g | ]}|j |j|jfqS r   )r   r   r   )r   r   r   r   r   r   "   s    )	r   r   add_patternsadd_pipeentsr   to_disk	from_diskAssertionError)r   nlprulerpatternsdocresnlp_reloadedd	file_pathruler_reloadeddoc_reloadedres_reloadedr   r   r   'test_issue4651_with_phrase_matcher_attr
   s"    



r'   c           	   C   s   d} t  }t|}ddddg}|| || || }dd |jD }t  }t &}|d }|| t||}	W d	Q R X ||	 || }
d
d |
jD }||kstd	S )zTest that the EntityRuler PhraseMatcher is deserialize correctly using
    the method from_disk when the EntityRuler argument phrase_matcher_attr is
    not specified.
    z!Spacy is a python library for nlpr   r   r	   )r
   r   r   c             S   s   g | ]}|j |j|jfqS r   )r   r   r   )r   r   r   r   r   r   5   s    z>test_issue4651_without_phrase_matcher_attr.<locals>.<listcomp>r   Nc             S   s   g | ]}|j |j|jfqS r   )r   r   r   )r   r   r   r   r   r   ?   s    )	r   r   r   r   r   r   r   r   r   )r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r   r   r   *test_issue4651_without_phrase_matcher_attr'   s"    



r(   N)

__future__r   Zspacy.lang.enr   Zspacy.pipeliner   utilr   r'   r(   r   r   r   r   <module>   s
   