o
    Mf2                     @   sv   d dl Z d dlmZ d dlmZmZ d dlmZmZm	Z	m
Z
mZmZmZmZmZmZ d dlmZ G dd de jZdS )    N)brown)JSONTaggedDecoderJSONTaggedEncoder)
AffixTaggerBigramTaggerBrillTaggerBrillTaggerTrainerDefaultTaggerNgramTaggerPerceptronTaggerRegexpTaggerTrigramTaggerUnigramTagger)
nltkdemo18c                   @   sD   e Zd Zdd Zdd Zdd Zdd Zd	d
 Zdd Zdd Z	dS )TestJSONSerializationc                 C   s0   t  d d | _t | _t | _td| _d S )N#   NN)	r   tagged_sentscorpusr   decoderr   encoderr	   default_tagger)self r   h/var/www/html/analyze/labelStudio/lib/python3.10/site-packages/nltk/test/unit/test_json_serialization.pysetUp   s   zTestJSONSerialization.setUpc                 C   sF   | j | j}| j|}| t| jt| | | jj|j d S )N)r   encoder   r   decodeassertEqualrepr_tag)r   encodeddecodedr   r   r   test_default_tagger   s   z)TestJSONSerialization.test_default_taggerc                 C   sh   t dg| jd}| j|}| j|}| t|t| | t|jt|j | |j	|j	 d S )N)z.*r   backoff)
r   r   r   r   r   r   r   r   r%   _regexpsr   taggerr!   r"   r   r   r   test_regexp_tagger"   s   z(TestJSONSerialization.test_regexp_taggerc                 C   s   t | j| jd}| j|}| j|}| t|t| | t|j	t|j	 | |j
|j
 | |j|j | |j|j d S )Nr$   )r   r   r   r   r   r   r   r   r   r%   _affix_length_min_word_length_context_to_tagr'   r   r   r   test_affix_tagger,   s   z'TestJSONSerialization.test_affix_taggerc                 C   s   t | j| jd}t| j|d}t| j|d}td| j|d}| j|}| j	|}| 
t|t| | 
t|t|j | 
t|t|jj | 
t|t|jjj | 
t| jt|jjjj d S )Nr$      )r   r   r   r   r   r
   r   r   r   r   r   r   r%   )r   	unitaggerbitagger	tritaggerntaggerr!   r"   r   r   r   test_ngram_taggers8   s   z(TestJSONSerialization.test_ngram_taggersc                 C   sf   t dd}|| j | j|}| j|}| |jj	|jj	 | |j
|j
 | |j|j d S )NF)load)r   trainr   r   r   r   r   r   modelweightstagdictclassesr'   r   r   r   test_perceptron_taggerI   s   
z,TestJSONSerialization.test_perceptron_taggerc                 C   sv   t | jt dd}|j| jdd}| j|}| j|}| 	t
|jt
|j | 	|j|j | 	|j|j d S )NT)deterministic   )	max_rules)r   r   r   r5   r   r   r   r   r   r   r   _initial_tagger_rules_training_stats)r   trainerr(   r!   r"   r   r   r   test_brill_taggerT   s   
z'TestJSONSerialization.test_brill_taggerN)
__name__
__module____qualname__r   r#   r)   r-   r3   r:   rB   r   r   r   r   r      s    
r   )unittestnltk.corpusr   nltk.jsontagsr   r   nltk.tagr   r   r   r   r	   r
   r   r   r   r   nltk.tag.brillr   TestCaser   r   r   r   r   <module>   s    0