
    g                     J    d dl Z d dlZd dlmZ  G d de j                        Zy)    N)CFGc                       e Zd Zd Zd Zy)ChomskyNormalFormForCFGTestc                    t        j                  d      }| j                  |j                                | j                  |j	                                |j                  d      }| j                  |j                                | j                  |j	                                t        j                  d      }| j                  |j                                | j                  |j	                                |j                         }| j                  |j                                | j                  |j	                                y )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grammar2s      T/var/www/openai/venv/lib/python3.12/site-packages/nltk/test/unit/test_cfg2chomsky.pytest_simplez'ChomskyNormalFormForCFGTest.test_simple   s    ..

 	@@BC779:--t-<??AB779:>>
 	AACD88:;//1@@BC779:    c                 ^   t         j                  j                  d      }| j                  |j	                                | j                  |j                                |j                  d      }| j                  |j	                                | j                  |j                                y )Nz grammars/large_grammars/atis.cfgTr   )nltkdataloadr
   r   r   r   r   )r   r   s     r   test_complexz(ChomskyNormalFormForCFGTest.test_complex+   s    ))..!CD@@BC779:--t-<??AB779:r   N)__name__
__module____qualname__r   r    r   r   r   r      s    !;F;r   r   )unittestr   nltk.grammarr   TestCaser   r   r   r   <module>r!      s       *;("3"3 *;r   