Example #1
0
def test_translate_john_is_bad(lexicon):
    nodes = translate_sentence("John is bad", lexicon)

    assert len(nodes) == 1

    node = nodes[0]
    assert node.text == "John is bad"
    assert node.formula == Call(Var("Bad"), Var("john"))
    assert node.type == TYPE_TRUTH_VALUE
Example #2
0
def test_translate_the_child(lexicon):
    nodes = translate_sentence("the child", lexicon)

    assert len(nodes) == 1

    node = nodes[0]
    assert node.text == "the child"
    assert node.formula == Iota("x", Call(Var("Child"), Var("x")))
    assert node.type == TYPE_ENTITY
Example #3
0
def test_translate_every_child_is_good(lexicon):
    nodes = translate_sentence("every child is good", lexicon)

    assert len(nodes) == 1

    node = nodes[0]
    assert node.text == "every child is good"
    assert node.formula == ForAll(
        "x", IfThen(Call(Var("Child"), Var("x")), Call(Var("Good"), Var("x"))))
    assert node.type == TYPE_TRUTH_VALUE
Example #4
0
def test_translate_is_good(lexicon):
    # import pdb; pdb.set_trace()
    nodes = translate_sentence("is good", lexicon)

    assert len(nodes) == 1

    node = nodes[0]
    assert node.text == "is good"
    assert node.formula == Lambda("x", Call(Var("Good"), Var("x")))
    assert node.type == TYPE_ET
Example #5
0
def test_translate_unknown_word_in_sentence(lexicon):
    nodes = translate_sentence("John is whorlious", lexicon)

    assert len(nodes) == 2

    # TODO [2019-05-20]: For now, this is just wrong (but wrong in the expected way).
    assert nodes[0].text == "John is whorlious"
    assert nodes[0].formula == Call(Var("Whorlious"), Var("john"))
    assert nodes[0].type == TYPE_TRUTH_VALUE

    assert nodes[1].text == "John is whorlious"
    assert nodes[1].formula == Call(Var("John"), Var("whorlious"))
    assert nodes[1].type == TYPE_TRUTH_VALUE
Example #6
0
def test_translate_unknown_word(lexicon):
    nodes = translate_sentence("Mikhail", lexicon)

    assert len(nodes) == 3

    assert nodes[0].text == "Mikhail"
    assert nodes[0].formula == Var("mikhail")
    assert nodes[0].type == TYPE_ENTITY

    assert nodes[1].text == "Mikhail"
    assert nodes[1].formula == Lambda("x", Call(Var("Mikhail"), Var("x")))
    assert nodes[1].type == TYPE_ET

    assert nodes[2].text == "Mikhail"
    assert nodes[2].formula == Lambda(
        "x", Lambda("y", Call(Call(Var("Mikhail"), Var("x")), Var("y"))))
    assert nodes[2].type == ComplexType(TYPE_ENTITY, TYPE_ET)
Example #7
0
def test_john_is_bad_is_false(lexicon):
    nodes = translate_sentence("John is bad", lexicon)

    assert len(nodes) == 1
    assert not interpret_formula(nodes[0].formula, test_model)
Example #8
0
def test_john_is_good_is_true(lexicon):
    nodes = translate_sentence("John is good", lexicon)

    assert len(nodes) == 1
    assert interpret_formula(nodes[0].formula, test_model)