
    gI                     Z    d Z ddlZddlZddlmZ ddlmZ  G d dej                        Zy)z.
Tests for NIST translation evaluation metric
    N)find)corpus_nistc                       e Zd Zd Zy)TestNISTc                 H   t        d      }t        d      }t        d      }t        |      5 }t        t        |j	                         d   j                         dd       }d d d        t        |d      5 }t        |d      5 }t        t        d	 |            }t        t        d
 |            }	t        t        dd            D ]%  \  }
}t        |	||
      }t        ||z
        dk  r%J  	 d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   y xY w)Nzmodels/wmt15_eval/ref.ruzmodels/wmt15_eval/google.ruz#models/wmt15_eval/mteval-13a.output   utf8)encodingc                 "    | j                         S Nsplitxs    W/var/www/openai/venv/lib/python3.12/site-packages/nltk/test/unit/translate/test_nist.py<lambda>z-TestNIST.test_sentence_nist.<locals>.<lambda>   s
    	    c                 $    | j                         gS r   r   r   s    r   r   z-TestNIST.test_sentence_nist.<locals>.<lambda>   s    r   
   g?)r   openmapfloat	readlinesr   listzipranger   abs)selfref_filehyp_filemteval_output_file
mteval_finmteval_nist_scoresref_finhyp_fin
hypotheses
referencesimteval_nist	nltk_nists                r   test_sentence_nistzTestNIST.test_sentence_nist   s   2356!"GH $% "%UJ,@,@,B2,F,L,L,NqQS,T!U &
 (V,h0G "#&97"CD
!#&;W"EF
&)%2,8J&KNA{ +J
A FI{Y67$>>> 'L 1 -, &% 10 -,s6   3D 5DA'D+D/D D	D	DD!N)__name__
__module____qualname__r-    r   r   r   r      s    ?r   r   )	__doc__iounittest	nltk.datar   nltk.translate.nist_scorer   TestCaser   r1   r   r   <module>r8      s*    
   1?x   ?r   