Fixed #100 : SheerkaAdmin: Add builtins() command

Fixed #99 : SheerkaQueryManager: I can manage contains predicate when filtering objects
Fixed #97 : ERROR: list indices must be integers or slices, not Concept
Fixed #96 : SequenceNodeParser: SequenceNodeParser must correctly handle concept definition
Fixed #95 : ResolveAmbiguity must not remove concepts that do not require evaluation
Fixed #94 : Concepts with the same key are lost when new ontology
Fixed #93 : Introduce BuiltinConcepts.EVAL_GLOBAL_TRUTH_REQUESTED
Fixed #92 : ExpressionParser: Implement compile_disjunctions()
Fixed #91 : Implement get_concepts_complexity(context, concepts, concept_parts)
Fixed #90 : ResolveAmbiguity : where predicate is not used to resolve ambiguity
Fixed #89 : ResolveAmbiguityEvaluator: Concepts embedded in ConceptNode are not resolved
Fixed #88: SyaNodeParser: Parse multiple parameters when some of the are not recognized
Fixed #87: SyaNodeParser : Parse the multiple parameters
This commit is contained in:
2021-07-31 08:52:00 +02:00
parent 7dcaa9c111
commit e69745adc8
70 changed files with 1561 additions and 455 deletions
+25 -33
View File
@@ -11,7 +11,7 @@ from core.sheerka.services.SheerkaHistoryManager import SheerkaHistoryManager
from core.sheerka.services.SheerkaMemory import SheerkaMemory
from core.sheerka.services.sheerka_service import BaseService
CONCEPTS_FILE_FULL = "full.sb"
CONCEPTS_FILE_FULL = "full.sb" # .sb for sheerka backup
CONCEPTS_FILE_TO_USE = CONCEPTS_FILE_FULL
@@ -22,24 +22,24 @@ class SheerkaAdmin(BaseService):
super().__init__(sheerka)
def initialize(self):
self.sheerka.bind_service_method(self.caches_names, False)
self.sheerka.bind_service_method(self.cache, False)
self.sheerka.bind_service_method(self.restore, True)
self.sheerka.bind_service_method(self.concepts, False)
self.sheerka.bind_service_method(self.desc, False)
self.sheerka.bind_service_method(self.desc_evaluators, False)
self.sheerka.bind_service_method(self.desc_parsers, False)
self.sheerka.bind_service_method(self.extended_isinstance, False)
self.sheerka.bind_service_method(self.is_container, False)
self.sheerka.bind_service_method(self.format_rules, False)
self.sheerka.bind_service_method(self.exec_rules, False)
self.sheerka.bind_service_method(self.admin_push_ontology, True, as_name="push_ontology")
self.sheerka.bind_service_method(self.admin_pop_ontology, True, as_name="pop_ontology")
self.sheerka.bind_service_method(self.ontologies, False)
self.sheerka.bind_service_method(self.in_memory, False)
self.sheerka.bind_service_method(self.admin_history, False, as_name="history")
self.sheerka.bind_service_method(self.sdp, False)
self.sheerka.bind_service_method(self.atomic_def, False)
self.sheerka.bind_service_method(self.NAME, self.caches_names, False)
self.sheerka.bind_service_method(self.NAME, self.cache, False)
self.sheerka.bind_service_method(self.NAME, self.restore, True)
self.sheerka.bind_service_method(self.NAME, self.concepts, False)
self.sheerka.bind_service_method(self.NAME, self.builtins, False)
self.sheerka.bind_service_method(self.NAME, self.desc, False)
self.sheerka.bind_service_method(self.NAME, self.desc_evaluators, False)
self.sheerka.bind_service_method(self.NAME, self.desc_parsers, False)
self.sheerka.bind_service_method(self.NAME, self.extended_isinstance, False)
self.sheerka.bind_service_method(self.NAME, self.is_container, False)
self.sheerka.bind_service_method(self.NAME, self.format_rules, False)
self.sheerka.bind_service_method(self.NAME, self.exec_rules, False)
self.sheerka.bind_service_method(self.NAME, self.admin_push_ontology, True, as_name="push_ontology")
self.sheerka.bind_service_method(self.NAME, self.admin_pop_ontology, True, as_name="pop_ontology")
self.sheerka.bind_service_method(self.NAME, self.ontologies, False)
self.sheerka.bind_service_method(self.NAME, self.in_memory, False)
self.sheerka.bind_service_method(self.NAME, self.admin_history, False, as_name="history")
self.sheerka.bind_service_method(self.NAME, self.sdp, False)
def caches_names(self):
"""
@@ -138,9 +138,11 @@ class SheerkaAdmin(BaseService):
self.sheerka.save_execution_context = False
enable_process_return_values_previous_value = self.sheerka.enable_process_return_values
self.sheerka.enable_process_return_values = False
self.sheerka.add_to_context(BuiltinConcepts.EVAL_GLOBAL_TRUTH_REQUESTED)
nb_lines, nb_instructions, nb_lines_in_error, min_time, max_time = restore_from_file(backup_file)
self.sheerka.remove_fom_context(BuiltinConcepts.EVAL_GLOBAL_TRUTH_REQUESTED)
self.sheerka.enable_process_return_values = enable_process_return_values_previous_value
self.sheerka.save_execution_context = True
self.sheerka.during_restore = False
@@ -167,6 +169,10 @@ class SheerkaAdmin(BaseService):
concepts = sorted(self.sheerka.om.list(self.sheerka.CONCEPTS_BY_ID_ENTRY), key=lambda item: int(item.id))
return self.sheerka.new(BuiltinConcepts.TO_LIST, body=concepts)
def builtins(self):
builtins = sorted(self.sheerka.sheerka_methods.values(), key=lambda builtin_method: builtin_method.name)
return self.sheerka.new(BuiltinConcepts.TO_LIST, body=builtins)
def desc_evaluators(self):
evaluators = {k: sorted(v[0].items(), reverse=True)
for k, v in self.sheerka.services[SheerkaExecute.NAME].grouped_evaluators_cache.items()}
@@ -241,20 +247,6 @@ class SheerkaAdmin(BaseService):
return self.sheerka.isinstance(a, b)
@staticmethod
def atomic_def(a):
"""
Return the 'atomic definition' of a concept
a concept key stripped from its 'var' tokens
>>> assert atomic_def(Concept('a plus b').def_var("a").def_var("b")) == "plus"
>>> assert atomic_def(Concept('x is a y').def_var("x").def_var("y")) == "is a"
:param a:
:return:
"""
ensure_concept(a)
return a.get_atomic_def()
@staticmethod
def is_container(obj):
"""