o
    Mf¾  ã                   @   s2   d dl Z d dlZd dlmZ G dd„ de jƒZdS )é    N)ÚCFGc                   @   s   e Zd Zdd„ Zdd„ ZdS )ÚChomskyNormalFormForCFGTestc                 C   sœ   t  d¡}|  | ¡ ¡ |  | ¡ ¡ |jdd}|  | ¡ ¡ |  | ¡ ¡ t  d¡}|  | ¡ ¡ |  | ¡ ¡ | ¡ }|  | ¡ ¡ |  | ¡ ¡ d S )Nzù
          S -> NP VP
          PP -> P NP
          NP -> Det N | NP PP P
          VP -> V NP | VP PP
          VP -> Det
          Det -> 'a' | 'the'
          N -> 'dog' | 'cat'
          V -> 'chased' | 'sat'
          P -> 'on' | 'in'
        T©Úflexiblez
          S -> NP VP
          NP -> VP N P
          VP -> P
          N -> 'dog' | 'cat'
          P -> 'on' | 'in'
        )r   Ú
fromstringÚassertFalseÚis_flexible_chomsky_normal_formÚis_chomsky_normal_formÚchomsky_normal_formÚ
assertTrue)ÚselfÚgrammarÚgrammar2© r   úa/var/www/html/analyze/labelStudio/lib/python3.10/site-packages/nltk/test/unit/test_cfg2chomsky.pyÚtest_simple   s    ÿÿ	z'ChomskyNormalFormForCFGTest.test_simplec                 C   sT   t j d¡}|  | ¡ ¡ |  | ¡ ¡ |jdd}|  | ¡ ¡ |  | ¡ ¡ d S )Nz grammars/large_grammars/atis.cfgTr   )ÚnltkÚdataÚloadr   r   r	   r
   r   )r   r   r   r   r   Útest_complex+   s   z(ChomskyNormalFormForCFGTest.test_complexN)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   r      s    #r   )Úunittestr   Únltk.grammarr   ÚTestCaser   r   r   r   r   Ú<module>   s    