Exemplo n.º 1
0
def test_facts_are_equal():
    """ We may need to use EQUAL facts that are not the same object but has
        the same values """

    from pyknow.fact import Fact, C, L

    assert Fact(a=L("foo")) == Fact(a=L("foo"))
    assert Fact(a=L("foo"), b=C("bar")) == Fact(a=L("foo"), b=C("bar"))
Exemplo n.º 2
0
 class Person_KE(KnowledgeEngine):
     @Rule(NOT(ConflictResolver(resolved=L(True))),
           AND(Person(name=L("name"), age=C('age')),
               Person(name=L("name"), age=N("age"))))
     def same_name(self, age):
         nonlocal executions
         executions.append(age)
Exemplo n.º 3
0
 class Person_KE(KnowledgeEngine):
     @Rule(Person(name=L("name"), age=C('age')),
           Person(name=L("name"), age=N("age")))
     def same_name(self, age):
         nonlocal executions
         executions.append(age)
Exemplo n.º 4
0
 class Person_KE(KnowledgeEngine):
     @Rule(Person(name=C("name")),
           NOT(Person(surname=V('name'))))
     def same_name(self, name):
         nonlocal executions
         executions.append(name)
Exemplo n.º 5
0
def test_C_resolve():
    """ Test C Resolve """
    from pyknow.fact import C
    assert C('foo').resolve() == 'foo'