コード例 #1
0
def test_0():

    '''Test ``compile_parts``
    for term ``p_act``'''

    print("\ntest_0: compile_parts")

    p_act = PatternTxt('action', r"act ${{action_type}} ",
                       'a')
    
    subterms_values = {'action_type': r"rotate ${{obj}}",
                       'obj': r"sphere"}
    p_act.compile_parts(subterms_values)
    test_0 = p_act.value_lex
    print("\ntest_0 out:")
    print(test_0)
コード例 #2
0
def test_6():

    '''Test ``split_part``
    for term ``p_act``'''

    print("\ntest_6.0: compile_parts")

    p_act = PatternTxt('action', r"act ${{action_type}} ",
                       'a')

    subterms_values = {'action_type': r"rotate ${{obj}}",
                       'obj': r"sphere"}
    p_act.compile_parts(subterms_values)

    print('\n test_6.1: %s' % (p_act.value_lex))

    grammar_parts = get_tests_grammar_parts()
    sent = ("in act rotate sphere at 30"
            + " and act rotate sphere at 31")
    print("sent: %s" % (sent))
    p_act.set_grammar_parts(grammar_parts)
    out = p_act.split_part(p_act.value_lex, sent)
    print(out)