Improved PyhtonEvaluator in order to use methods that need context
This commit is contained in:
@@ -192,7 +192,7 @@ as:
|
||||
assert sheerka.isinstance(res[0].value, BuiltinConcepts.NOP)
|
||||
|
||||
def test_i_can_recognize_concept_with_variable(self):
|
||||
sheerka, context, concept_foo, concept_hello = self.init_concepts(
|
||||
sheerka, context, concept_foo, concept_hello = self.init_concepts(
|
||||
"foo",
|
||||
Concept(name="hello a").def_var("a"),
|
||||
create_new=True)
|
||||
@@ -869,6 +869,35 @@ as:
|
||||
# assert res[0].status
|
||||
# assert isinstance(res[0].body, Concept)
|
||||
|
||||
def test_i_can_express_comparison(self):
|
||||
definitions = [
|
||||
"def concept one",
|
||||
"def concept two",
|
||||
"def concept three",
|
||||
"def concept four",
|
||||
]
|
||||
|
||||
sheerka = self.init_scenario(definitions)
|
||||
|
||||
res = sheerka.evaluate_user_input("is_greater_than('some_prop', two, one)")
|
||||
assert res[0].status
|
||||
|
||||
res = sheerka.evaluate_user_input("is_less_than('some_prop', two, three)")
|
||||
assert res[0].status
|
||||
|
||||
res = sheerka.evaluate_user_input("get_concepts_weights('some_prop')")
|
||||
assert res[0].status
|
||||
assert res[0].body == {'1001': 1, '1002': 2, '1003': 3}
|
||||
|
||||
# test i use a concept to define relation
|
||||
sheerka.evaluate_user_input("def concept a > b as is_greater_than('some_prop', a, b)")
|
||||
res = sheerka.evaluate_user_input("eval four > three")
|
||||
assert res[0].status
|
||||
|
||||
res = sheerka.evaluate_user_input("get_concepts_weights('some_prop')")
|
||||
assert res[0].status
|
||||
assert res[0].body == {'1001': 1, '1002': 2, '1003': 3, '1004': 4}
|
||||
|
||||
|
||||
class TestSheerkaNonRegFile(TestUsingFileBasedSheerka):
|
||||
def test_i_can_def_several_concepts(self):
|
||||
|
||||
Reference in New Issue
Block a user