Working on #98 : Persist attribute value when global_truth is set to true

This commit is contained in:
2021-08-03 11:26:57 +02:00
parent e69745adc8
commit c798c2c570
22 changed files with 496 additions and 106 deletions
+10 -2
View File
@@ -21,6 +21,9 @@ from sdp.sheerkaDataProvider import Event
BASE_NODE_PARSER_CLASS = "parsers.BaseNodeParser.BaseNodeParser"
EXIT_COMMANDS = ("quit", "exit", "bye")
CONTEXT_HINT_COMMANDS = (("global_truth(", "global_truth"),
("question(", "question"),
("eval", "eval"))
EXECUTE_STEPS = [
BuiltinConcepts.BEFORE_PARSING,
BuiltinConcepts.PARSING,
@@ -493,7 +496,7 @@ class Sheerka(Concept):
c.get_hints().recognized_by = rec_by
c.get_hints().is_instance = is_inst
if is_eval is None:
c.get_hints().is_evaluated = len(c.get_metadata().variables) > 0
c.get_hints().is_evaluated = len(c.get_metadata().parameters) > 0
else:
c.get_hints().is_evaluated = is_eval
return c
@@ -581,7 +584,12 @@ class Sheerka(Concept):
# otherwise, create another instance
concept = self.builtin_cache[key]() if key in self.builtin_cache else Concept()
concept.update_from(template, update_value=False)
# concept.freeze_definition_hash()
# set the default values is needed
for var_name, var_value in concept.get_metadata().variables:
if isinstance(var_value, Concept):
concept.set_value(var_name, var_value)
# Note that the concept is not considered as evaluated. The body may need to be computed
if len(kwargs) == 0:
return concept