コード例 #1
0
ファイル: test_engine.py プロジェクト: telescopeuser/pyknow
    class Test(KnowledgeEngine):
        @Rule(InitialFact())
        def rule1(self):
            pass

        @Rule(InitialFact())
        def rule2(self):
            pass
コード例 #2
0
def test_prepare_rule__or_starting_with_not():
    from pyknow import Rule, InitialFact, NOT, Fact, OR, AND

    rule = Rule(OR(NOT(Fact(1)), NOT(Fact(2))))(lambda: None)

    assert list(utils.prepare_rule(rule)) == [
        OR(AND(InitialFact(), NOT(Fact(1))), AND(InitialFact(), NOT(Fact(2))))
    ]
コード例 #3
0
ファイル: test_engine.py プロジェクト: telescopeuser/pyknow
def test_KnowledgeEngine_has_initialfacts():
    from pyknow.engine import KnowledgeEngine
    from pyknow import InitialFact

    assert list(KnowledgeEngine()._declare_initial_fact()) == [InitialFact()]
コード例 #4
0
def test_prepare_rule__rule_starting_with_not():
    from pyknow import Rule, InitialFact, NOT, Fact

    rule = Rule(NOT(Fact(1)))(lambda: None)

    assert list(utils.prepare_rule(rule)) == [InitialFact(), NOT(Fact(1))]
コード例 #5
0
def test_prepare_rule_empty():
    from pyknow import Rule, InitialFact

    rule = Rule()(lambda: None)

    assert list(utils.prepare_rule(rule)) == [InitialFact()]