
    g                         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e j&                        Zy)    N)brown)JSONTaggedDecoderJSONTaggedEncoder)
AffixTaggerBigramTaggerBrillTaggerBrillTaggerTrainerDefaultTaggerNgramTaggerPerceptronTaggerRegexpTaggerTrigramTaggerUnigramTagger)
nltkdemo18c                   6    e Zd Zd Zd Zd Zd Zd Zd Zd Z	y)	TestJSONSerializationc                     t        j                         d d | _        t               | _        t               | _        t        d      | _        y )N#   NN)	r   tagged_sentscorpusr   decoderr   encoderr
   default_tagger)selfs    [/var/www/openai/venv/lib/python3.12/site-packages/nltk/test/unit/test_json_serialization.pysetUpzTestJSONSerialization.setUp   s:    ((*3B/(*(*+D1    c                 @   | j                   j                  | j                        }| j                  j	                  |      }| j                  t        | j                        t        |             | j                  | j                  j                  |j                         y )N)r   encoder   r   decodeassertEqualrepr_tag)r   encodeddecodeds      r   test_default_taggerz)TestJSONSerialization.test_default_tagger   so    ,,%%d&9&9:,,%%g.d112DMB,,117<<@r   c                    t        dg| j                        }| j                  j                  |      }| j                  j                  |      }| j                  t        |      t        |             | j                  t        |j                        t        |j                               | j                  |j                  |j                         y )N)z.*r   backoff)
r   r   r   r    r   r!   r"   r#   r*   _regexpsr   taggerr%   r&   s       r   test_regexp_taggerz(TestJSONSerialization.test_regexp_tagger"   s    }ot7J7JK,,%%f-,,%%g.ftG}5fnn-tGOO/DE'*:*:;r   c                 N   t        | j                  | j                        }| j                  j	                  |      }| j
                  j                  |      }| j                  t        |      t        |             | j                  t        |j                        t        |j                               | j                  |j                  |j                         | j                  |j                  |j                         | j                  |j                  |j                         y )Nr)   )r   r   r   r   r    r   r!   r"   r#   r*   _affix_length_min_word_length_context_to_tagr,   s       r   test_affix_taggerz'TestJSONSerialization.test_affix_tagger,   s    T[[$2E2EF,,%%f-,,%%g.ftG}5fnn-tGOO/DE--w/D/DE00'2J2JK//1H1HIr   c                    t        | j                  | j                        }t        | j                  |      }t	        | j                  |      }t        d| j                  |      }| j                  j                  |      }| j                  j                  |      }| j                  t        |      t        |             | j                  t        |      t        |j                               | j                  t        |      t        |j                  j                               | j                  t        |      t        |j                  j                  j                               | j                  t        | j                        t        |j                  j                  j                  j                               y )Nr)      )r   r   r   r   r   r   r   r    r   r!   r"   r#   r*   )r   	unitaggerbitagger	tritaggerntaggerr%   r&   s          r   test_ngram_taggersz(TestJSONSerialization.test_ngram_taggers8   s,   !$++t7J7JK	Y?!$++x@	ai@,,%%g.,,%%g.gW6i$w*?@hgoo.E.E)FGi$w/F/F/N/N*OP$$%tGOO,C,C,K,K,S,S'T	
r   c                    t        d      }|j                  | j                         | j                  j	                  |      }| j
                  j                  |      }| j                  |j                  j                  |j                  j                         | j                  |j                  |j                         | j                  |j                  |j                         y )NF)load)r   trainr   r   r    r   r!   r"   modelweightstagdictclassesr,   s       r   test_perceptron_taggerz,TestJSONSerialization.test_perceptron_taggerI   s    !u-T[[!,,%%f-,,%%g.--w}}/D/DE99r   c                    t        | j                  t               d      }|j                  | j                  d      }| j
                  j                  |      }| j                  j                  |      }| j                  t        |j                        t        |j                               | j                  |j                  |j                         | j                  |j                  |j                         y )NT)deterministic   )	max_rules)r	   r   r   r=   r   r   r    r   r!   r"   r#   _initial_tagger_rules_training_stats)r   trainerr-   r%   r&   s        r   test_brill_taggerz'TestJSONSerialization.test_brill_taggerT   s    $T
 t{{b9,,%%f-,,%%g.f445tG<S<S7TU7//1H1HIr   N)
__name__
__module____qualname__r   r'   r.   r3   r:   rB   rK    r   r   r   r      s(    2A<
J
"	:Jr   r   )unittestnltk.corpusr   nltk.jsontagsr   r   nltk.tagr   r   r   r	   r
   r   r   r   r   r   nltk.tag.brillr   TestCaser   rO   r   r   <module>rV      s8      >   &KJH-- KJr   