
    c                     N   d Z ddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZ dZdZdZdZdZd	 eeeefD             Z ej        d
dgd
dgdd
gdd
gg          Z G d dej                  Zedk    r' ej        ej                    ej                      dS dS )z)
Automated tests for the parsing module.
    N)remove_short_tokensremove_stopword_tokensremove_stopwords	stem_textsplit_alphanumsplit_on_spacestrip_multiple_whitespacesstrip_non_alphanumstrip_numericstrip_punctuationstrip_short
strip_tagsu   C'est un trou de verdure où chante une rivière,
Accrochant follement aux herbes des haillons
D'argent ; où le soleil, de la montagne fière,
Luit : c'est un petit val qui mousse de rayons.u   Un soldat jeune, bouche ouverte, tête nue,
Et la nuque baignant dans le frais cresson bleu,
Dort ; il est étendu dans l'herbe, sous la nue,
Pâle dans son lit vert où la lumière pleut.u   Les pieds dans les glaïeuls, il dort. Souriant comme
Sourirait un enfant malade, il fait un somme :
Nature, berce-le chaudement : il a froid.u   Les parfums ne font pas frissonner sa narine ;
Il dort dans le soleil, la main sur sa poitrine,
Tranquille. Il a deux trous rouges au côté droit.zWhile it is quite useful to be able to search a
large collection of documents almost instantly for a joint
occurrence of a collection of exact words,
for many searching purposes, a little fuzziness would help. c                 P    g | ]#}t          |                                          $S  )r   lower).0xs     8lib/python3.11/site-packages/gensim/test/test_parsing.py
<listcomp>r   6   s)    
J
J
JAQWWYY''
J
J
J       c                   P    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd ZdS )TestPreprocessingc                 L    |                      t          d          d           d S )Nsalut les amis du 59zsalut les amis du )assertEqualr   selfs    r   test_strip_numericz$TestPreprocessing.test_strip_numeric=   s(    '=>>@TUUUUUr   c                 N    |                      t          dd          d           d S )Nr      zsalut les amis)r   r   r   s    r   test_strip_shortz"TestPreprocessing.test_strip_short@   s*    %;Q??AQRRRRRr   c                 L    |                      t          d          d           d S )Nz<i>Hello</i> <b>World</b>!zHello World!)r   r   r   s    r   test_strip_tagsz!TestPreprocessing.test_strip_tagsC   s'    $@AA>RRRRRr   c                 L    |                      t          d          d           d S )Nzsalut  les
loulous!zsalut les loulous!)r   r	   r   s    r   test_strip_multiple_whitespacesz1TestPreprocessing.test_strip_multiple_whitespacesF   s)    34LMMOcdddddr   c                 L    |                      t          d          d           d S )Nztoto nf-kappa titiztoto nf kappa titi)r   r
   r   s    r   test_strip_non_alphanumz)TestPreprocessing.test_strip_non_alphanumI   s)    +,@AACWXXXXXr   c                     |                      t          d          d           |                      t          d          d           d S )Nztoto diet1 titiztoto diet 1 titiztoto 1diet titiztoto 1 diet titi)r   r   r   s    r   test_split_alphanumz%TestPreprocessing.test_split_alphanumL   sH    (9::<NOOO(9::<NOOOOOr   c                 
   |                      t          d          d           t          j        dt	          dg                    5  |                      t          d          d           d d d            d S # 1 swxY w Y   d S )Nzthe world is squarezworld square&gensim.parsing.preprocessing.STOPWORDSthezworld is square)r   r   mockpatch	frozensetr   s    r   test_strip_stopwordsz&TestPreprocessing.test_strip_stopwordsP   s    )*?@@.QQQ Z@)UGBTBTUU 	Y 	Y-.CDDFWXXX	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Y 	Ys   $A88A<?A<c                    |                      t          g d          ddg           t          j        dt	          dg                    5  |                      t          g d          g d           d d d            d S # 1 swxY w Y   d S )N)r-   worldisspherer3   r5   r,   r-   )r3   r4   r5   )r   r   r.   r/   r0   r   s    r   test_strip_stopword_tokensz,TestPreprocessing.test_strip_stopword_tokensW   s    /0P0P0PQQT[]eSfggg Z@)UGBTBTUU 	 	&'G'G'GHH)))  	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   (B  BBc                 V    |                      t          g dd          g d           d S )Nsalutlesamisdu59r!   )r9   r:   r;   )r   r   r   s    r   test_strip_short_tokensz)TestPreprocessing.test_strip_short_tokensa   s8    ,-Q-Q-QSTUUWoWoWopppppr   c                 P    |                      t          d          g d           d S )Nz salut   les  amis du 59 r8   )r   r   r   s    r   test_split_on_spacez%TestPreprocessing.test_split_on_spaced   s.    (CDDFjFjFjkkkkkr   c                 Z    d}|                      t          t                    |           d S )Nzwhile it is quit us to be abl to search a larg collect of document almost instantli for a joint occurr of a collect of exact words, for mani search purposes, a littl fuzzi would help.)r   r   doc5)r   targets     r   test_stem_textz TestPreprocessing.test_stem_textg   s0    ( 	
 	4&11111r   N)__name__
__module____qualname__r   r"   r$   r&   r(   r*   r1   r6   r>   r@   rD   r   r   r   r   r   ;   s        V V VS S SS S Se e eY Y YP P PY Y Y  q q ql l l2 2 2 2 2r   r   __main__)level)!__doc__loggingunittestr.   numpynpgensim.parsing.preprocessingr   r   r   r   r   r   r	   r
   r   r   r   r   doc1doc2doc3doc4rB   datasetarrayclassesTestCaser   rE   basicConfigWARNINGmainr   r   r   <module>r[      s                                      3
2
-7@ K
J$dD1I
J
J
J
"(QFQFQFQF3
4
422 22 22 22 22) 22 22 22j z Ggo....HMOOOOO r   