71d1b1d1ca
Fixed #103 : Implement PlurialNodeParser Fixed #104 : Implement dynamic concept Fixed #107 : PrepareEvalxxxEvaluator: context hints are lost on a second evaluation
58 lines
1.9 KiB
Python
58 lines
1.9 KiB
Python
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
|
|
|
|
|
|
class TestSheerkaNonRegMemory2(TestUsingMemoryBasedSheerka):
|
|
|
|
def test_i_can_select_the_correct_concept_when_ambiguity(self):
|
|
init = [
|
|
"def concept foo",
|
|
"def concept x is a y pre is_question() as isa(x,y)",
|
|
"def concept x is a foo pre is_question() as isinstance(x, foo)",
|
|
]
|
|
sheerka = self.init_scenario(init)
|
|
|
|
res = sheerka.evaluate_user_input("question(foo is a foo)")
|
|
|
|
assert len(res) == 1
|
|
assert res[0].status
|
|
assert res[0].value # value is True since 'x is a foo' was chosen
|
|
|
|
def test_i_can_select_the_correct_concept_vs_bnf(self):
|
|
init = [
|
|
"def concept one as 1",
|
|
"def concept two as 2",
|
|
"def concept twenties from bnf 'twenty' (one|two)=unit as 20 + unit",
|
|
"def concept twenty two as 'specific occurrence'",
|
|
]
|
|
sheerka = self.init_scenario(init)
|
|
|
|
res = sheerka.evaluate_user_input("eval twenty one")
|
|
assert res[0].value == 21
|
|
|
|
res = sheerka.evaluate_user_input("eval twenty two")
|
|
assert res[0].value == "specific occurrence" # thanks to ExactConceptParser
|
|
|
|
def test_i_can_use_global_truth_when_calling_a_concept(self):
|
|
init = [
|
|
"def concept one",
|
|
"def concept number",
|
|
"def concept x is a y as set_isa(x, y)",
|
|
]
|
|
sheerka = self.init_scenario(init)
|
|
|
|
res = sheerka.evaluate_user_input("global_truth(one is a number)")
|
|
|
|
assert res[0].status
|
|
assert sheerka.isa(sheerka.new("one"), sheerka.new("number"))
|
|
|
|
# def test_i_can_define_plural(self):
|
|
# init = [
|
|
# "def concept man",
|
|
# "def concept men as set_plural(man) ret man auto_eval True",
|
|
# ]
|
|
# sheerka = self.init_scenario(init)
|
|
#
|
|
# res = sheerka.evaluate_user_input("men")
|
|
# assert res[0].status
|
|
|