Example #1
0
def test_expressions():
    kb = KnowledgeBase([('i', 'like', 'cookies'), ('i', 'like', 'milk'),
                        ('i', 'type', 'person'), ('i', 'type', 'living_thing'),
                        ('cookies', 'quality', 'good')])
    assert kb.expressions('i') == {'i'}
    assert kb.expressions('living_thing') == set()
    kb.add_expression('living_thing', 'life')
    kb.add_expression('living_thing', 'alive')
    assert kb.expressions('living_thing') == {'life', 'alive'}
Example #2
0
def test_expressions():
    kb = KnowledgeBase(
        [
            ("i", "like", "cookies"),
            ("i", "like", "milk"),
            ("i", "type", "person"),
            ("i", "type", "living_thing"),
            ("cookies", "quality", "good"),
        ]
    )
    assert kb.expressions("i") == {"i"}
    assert kb.expressions("living_thing") == set()
    kb.add_expression("living_thing", "life")
    kb.add_expression("living_thing", "alive")
    assert kb.expressions("living_thing") == {"life", "alive"}