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"))
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)
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)
class Person_KE(KnowledgeEngine): @Rule(Person(name=C("name")), NOT(Person(surname=V('name')))) def same_name(self, name): nonlocal executions executions.append(name)
def test_C_resolve(): """ Test C Resolve """ from pyknow.fact import C assert C('foo').resolve() == 'foo'