Fixed #49 : working
This commit is contained in:
@@ -1085,40 +1085,10 @@ isinstance(var, Concept) and var.key == 'hello __var__0'""" + \
|
||||
"#__x_01__|__is_concept__|True",
|
||||
"#__x_01__|name|'greetings'"]
|
||||
),
|
||||
(
|
||||
"recognize by name and variable sheerka",
|
||||
"recognize(__ret.body, greetings, a=sheerka)",
|
||||
"sheerka",
|
||||
["#__x_00__|__name__|'__ret'",
|
||||
"#__x_00__|body|#__x_01__",
|
||||
"#__x_01__|__is_concept__|True",
|
||||
"#__x_01__|name|'greetings'",
|
||||
"#__x_01__|a|'__sheerka__'"]
|
||||
),
|
||||
(
|
||||
"recognize by name and str variable",
|
||||
"recognize(__ret.body, greetings, a='my friend')",
|
||||
"'my friend'",
|
||||
["#__x_00__|__name__|'__ret'",
|
||||
"#__x_00__|body|#__x_01__",
|
||||
"#__x_01__|__is_concept__|True",
|
||||
"#__x_01__|name|'greetings'",
|
||||
"#__x_01__|a|'my friend'"]
|
||||
),
|
||||
(
|
||||
"recognize by name and concept variable",
|
||||
"recognize(__ret.body, greetings, a=foo)",
|
||||
"foo",
|
||||
["#__x_00__|__name__|'__ret'",
|
||||
"#__x_00__|body|#__x_01__",
|
||||
"#__x_01__|__is_concept__|True",
|
||||
"#__x_01__|name|'greetings'",
|
||||
"#__x_01__|a.name|'foo'"]
|
||||
),
|
||||
(
|
||||
"recognize by name and add other conditions (str)",
|
||||
"recognize(__ret.body, greetings) and __ret.body.a == 'my friend'",
|
||||
"foo",
|
||||
"my friend",
|
||||
["#__x_00__|__name__|'__ret'",
|
||||
"#__x_00__|body|#__x_01__",
|
||||
"#__x_01__|__is_concept__|True",
|
||||
@@ -1128,12 +1098,12 @@ isinstance(var, Concept) and var.key == 'hello __var__0'""" + \
|
||||
(
|
||||
"recognize by name and add other conditions (sheerka)",
|
||||
"recognize(__ret.body, greetings) and __ret.body.a == sheerka",
|
||||
"foo",
|
||||
"sheerka",
|
||||
["#__x_00__|__name__|'__ret'",
|
||||
"#__x_00__|body|#__x_01__",
|
||||
"#__x_01__|__is_concept__|True",
|
||||
"#__x_01__|name|'greetings'",
|
||||
"#__x_01__|a|'kodjo'"]
|
||||
"#__x_01__|a|'__sheerka__'"]
|
||||
),
|
||||
(
|
||||
"recognize by name and add other conditions (concept)",
|
||||
@@ -1143,8 +1113,21 @@ isinstance(var, Concept) and var.key == 'hello __var__0'""" + \
|
||||
"#__x_00__|body|#__x_01__",
|
||||
"#__x_01__|__is_concept__|True",
|
||||
"#__x_01__|name|'greetings'",
|
||||
"#__x_01__|a|'kodjo'"]
|
||||
"#__x_01__|a|#__x_02__",
|
||||
"#__x_02__|__is_concept__|True",
|
||||
"#__x_02__|name|'foo'"]
|
||||
),
|
||||
(
|
||||
"recognize by instance",
|
||||
"recognize(__ret.body, hello sheerka)",
|
||||
"foo",
|
||||
["#__x_00__|__name__|'__ret'",
|
||||
"#__x_00__|body|#__x_01__",
|
||||
"#__x_01__|__is_concept__|True",
|
||||
"#__x_01__|key|'hello __var__0'",
|
||||
"#__x_01__|a|__sheerka__"]
|
||||
),
|
||||
|
||||
])
|
||||
def test_i_can_get_rete_conditions_from_recognized(self, test_name, expression, variable_name, expected_as_str):
|
||||
sheerka, context, greetings, foo = self.init_test().with_concepts(
|
||||
@@ -1173,7 +1156,7 @@ isinstance(var, Concept) and var.key == 'hello __var__0'""" + \
|
||||
rule.rete_disjunctions = conditions
|
||||
network.add_rule(rule)
|
||||
|
||||
variable = foo if variable_name == "foo" else variable_name
|
||||
variable = foo if variable_name == "foo" else sheerka if variable_name == "sheerka" else variable_name
|
||||
to_recognize = sheerka.new_from_template(greetings, greetings.key, a=variable)
|
||||
network.add_obj("__ret", ReturnValueConcept("Test", True, to_recognize))
|
||||
matches = list(network.matches)
|
||||
|
||||
Reference in New Issue
Block a user