Exemple #1
0
def test_cyk_3():
    test_path = os.path.join(os.getcwd(), 'tests/data/cyk/test3')

    grammar = GrammarAlgos.from_grammar_file(
        os.path.join(test_path, 'grammar.txt'))

    assert GrammarAlgos.CYK(grammar, 'aabab')
    assert GrammarAlgos.CYK(grammar, 'bbbb')
    assert GrammarAlgos.CYK(grammar, 'aaabb')
    assert not GrammarAlgos.CYK(grammar, 'ab')
    assert not GrammarAlgos.CYK(grammar, 'aabbab')
def run_cyk_on_script(script):
    grammar = GrammarAlgos.from_grammar_file('src/db-language/grammar.txt',
                                             python_regex=True,
                                             nonterms_upper=False)
    script_prepared = prepare_script(script)
    return GrammarAlgos.CYK(grammar, script_prepared)