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"))