Implemented some enhancement request and fixed some bugs
Fixed #2 : Variables are not recognized when inside a rule token Fixed #15 : Rule: rete attributes are lost when a new ontology is created Fixed #14 : ReteNetwork: Format rules must not be added to Rete network Fixed #16 : DefConcept: Variables are not recognized when they are keyword arguments Fixed #4 : Comparison are not correctly set when comparison property is a concept Fixed #14 : Parser: merge FunctionParser.NamesNode and ExpressionParser.NamesNode Fixed #18 : Parser: Add SourceCodeNode test to UnrecognizedNodeParser Fixed #20 : At startup Number concept is saved in db a numerous number of time Fixed #21 : CacheManager: I can remove all elements from a ListIfNeededCache and fill it again Fixed #22 : CacheManager: I can remove all elements from a SetCache and fill it again Fixed #23 : HistoryManager: history() no longer works Fixed #24 : HistoryManager: history() no longer works after creating an exec rule Fixed #25 : SheerkaMemory: Use MemoryObject instead of sheerka.local Fixed #26 : Debugger: add the list all available services.. Fixed #27 : CONCEPTS_GRAMMARS_ENTRY does not seems to be in use any more Fixed #28 : Give order to services
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from core.builtin_concepts import BuiltinConcepts
|
||||
from core.concept import Concept, PROPERTIES_TO_SERIALIZE, simplec, CMV, CC
|
||||
from core.global_symbols import NotInit
|
||||
@@ -6,9 +7,7 @@ from core.sheerka.services.SheerkaConceptManager import SheerkaConceptManager
|
||||
from evaluators.MutipleSameSuccessEvaluator import MultipleSameSuccessEvaluator
|
||||
from evaluators.OneSuccessEvaluator import OneSuccessEvaluator
|
||||
from evaluators.PythonEvaluator import PythonEvalError
|
||||
from parsers.BaseNodeParser import SyaAssociativity
|
||||
from parsers.BnfNodeParser import Sequence, StrMatch, OrderedChoice, Optional, ConceptExpression
|
||||
|
||||
from tests.TestUsingFileBasedSheerka import TestUsingFileBasedSheerka
|
||||
from tests.TestUsingMemoryBasedSheerka import TestUsingMemoryBasedSheerka
|
||||
|
||||
@@ -875,9 +874,9 @@ as:
|
||||
assert res[0].status
|
||||
|
||||
assert sheerka.get_weights("some_prop") == {'c:one|1001:': 1,
|
||||
'c:two|1002:': 2,
|
||||
'c:three|1003:': 3,
|
||||
'c:four|1004:': 4}
|
||||
'c:two|1002:': 2,
|
||||
'c:three|1003:': 3,
|
||||
'c:four|1004:': 4}
|
||||
|
||||
def test_i_can_evaluate_expression_when_using_token_concept(self):
|
||||
sheerka, context, one, two, three, is_less_than = self.init_concepts(
|
||||
@@ -949,7 +948,7 @@ as:
|
||||
sheerka = self.init_scenario(init)
|
||||
|
||||
# simulate that sheerka was stopped and restarted
|
||||
sheerka.om.clear(sheerka.CONCEPTS_GRAMMARS_ENTRY)
|
||||
sheerka.clear_bnf_definition()
|
||||
sheerka.om.get(SheerkaConceptManager.CONCEPTS_BY_KEY_ENTRY, "twenties").set_compiled({})
|
||||
|
||||
res = sheerka.evaluate_user_input("eval twenty one")
|
||||
@@ -1114,23 +1113,6 @@ as:
|
||||
assert len(res) == 1
|
||||
assert res[0].status
|
||||
|
||||
def test_i_can_eval_concepts_fed_with_functions(self):
|
||||
init = [
|
||||
"def concept inc a as a + 1",
|
||||
"def concept one as 1"
|
||||
]
|
||||
|
||||
def times_five(i):
|
||||
return i * 5
|
||||
|
||||
sheerka = self.init_scenario(init)
|
||||
sheerka.locals["times_five"] = times_five
|
||||
|
||||
res = sheerka.evaluate_user_input("eval inc times_five(one)")
|
||||
assert len(res) == 1
|
||||
assert res[0].status
|
||||
assert res[0].body == 6
|
||||
|
||||
def test_i_can_define_a_concept_when_where_clause_contains_the_name_of_the_variable(self):
|
||||
init = [
|
||||
"def concept x is a y as isa(x,y) pre is_question()",
|
||||
@@ -1231,7 +1213,8 @@ as:
|
||||
|
||||
def test_i_can_define_rules_priorities(self):
|
||||
sheerka, context, r1, r2 = self.init_test().with_format_rules(("True", "True"), ("False", "False")).unpack()
|
||||
sheerka.evaluate_user_input("def concept rule x > rule y where isinstance(x, int) and isinstance(y, int) as set_is_greater_than(__PRECEDENCE, r:|x:, r:|y:, 'Rule')")
|
||||
sheerka.evaluate_user_input(
|
||||
"def concept rule x > rule y where isinstance(x, int) and isinstance(y, int) as set_is_greater_than(__PRECEDENCE, r:|x:, r:|y:, 'Rule')")
|
||||
|
||||
res = sheerka.evaluate_user_input(f"eval rule {r1.id} > rule {r2.id}")
|
||||
|
||||
@@ -1242,6 +1225,18 @@ as:
|
||||
weights = sheerka.get_weights(BuiltinConcepts.PRECEDENCE, 'Rule')
|
||||
assert weights[r1.str_id] == weights[r2.str_id] + 1
|
||||
|
||||
def test_i_can_get_history_after_def_rule_parser(self):
|
||||
sheerka = self.get_sheerka()
|
||||
sheerka.save_execution_context = True
|
||||
sheerka.evaluate_user_input("when True then answer('that is true')")
|
||||
res = sheerka.evaluate_user_input("history()")
|
||||
|
||||
assert len(res) == 1
|
||||
assert res[0].status
|
||||
l = list(res[0].body.body)
|
||||
assert len(l) > 0
|
||||
sheerka.save_execution_context = False
|
||||
|
||||
|
||||
class TestSheerkaNonRegFile(TestUsingFileBasedSheerka):
|
||||
def test_i_can_def_several_concepts(self):
|
||||
|
||||
Reference in New Issue
Block a user