Fixed #109 : Mix python and concept. List comprehension

Fixed #110 : SheerkaDebugManager: add list_debug_settings
Fixed #111 : SheerkaDebugManager: Implement ListDebugLogger
Fixed #112 : SyaNodeParser: rewrite this parser
Fixed #113 : Sheerka.: Add enable_parser_caching to disable parsers caching
Fixed #114 : SyaNodeParser : Implement fast cache to resolve unrecognized tokens requests
Fixed #115 : BnfNodeParser : Implement fast cache to resolve unrecognized tokens requests
Fixed #116 : SequenceNodeParser : Implement fast cache to resolve unrecognized tokens requests
Fixed #117 : ResolveMultiplePluralAmbiguityEvaluator: Resolve Multiple plural ambiguity
This commit is contained in:
2021-09-06 11:51:50 +02:00
parent 71d1b1d1ca
commit 54e5681c5a
57 changed files with 5179 additions and 3125 deletions
+22 -7
View File
@@ -8,12 +8,12 @@ import core.utils
from cache.Cache import Cache
from cache.IncCache import IncCache
from core.builtin_concepts import ErrorConcept, ReturnValueConcept, UnknownConcept
from core.builtin_concepts_ids import BuiltinErrors, BuiltinConcepts
from core.builtin_concepts_ids import BuiltinConcepts, BuiltinErrors
from core.concept import Concept, ConceptParts, get_concept_attrs
from core.global_symbols import EVENT_USER_INPUT_EVALUATED, NotInit, NotFound, ErrorObj, EVENT_ONTOLOGY_CREATED
from core.global_symbols import EVENT_ONTOLOGY_CREATED, EVENT_USER_INPUT_EVALUATED, ErrorObj, NotFound, NotInit
from core.profiling import profile
from core.sheerka.ExecutionContext import ExecutionContext
from core.sheerka.SheerkaOntologyManager import SheerkaOntologyManager, OntologyAlreadyExists
from core.sheerka.SheerkaOntologyManager import OntologyAlreadyExists, SheerkaOntologyManager
from core.sheerka_logger import console_handler
from core.tokenizer import Token, TokenKind
from printer.SheerkaPrinter import SheerkaPrinter
@@ -119,6 +119,7 @@ class Sheerka(Concept):
self.enable_process_return_values = True
self.enable_process_rules = True
self.enable_commands_backup = True
self.enable_parser_caching = True
self.methods_with_context = {"test_using_context"} # only the names, the method is defined in sheerka_methods
self.pipe_functions = set()
@@ -193,6 +194,7 @@ class Sheerka(Concept):
self.enable_process_return_values)
self.enable_process_rules = kwargs.get("enable_process_rules", self.enable_process_rules)
self.enable_commands_backup = kwargs.get("enable_commands_backup", self.enable_commands_backup)
self.enable_parser_caching = kwargs.get("enable_parser_caching", self.enable_parser_caching)
try:
self.during_initialisation = True
@@ -449,8 +451,8 @@ class Sheerka(Concept):
concept = concept.value # concept is now a tuple
if isinstance(concept, str) and \
concept.startswith("c:") and \
(tmp := core.utils.unstr_concept(concept)) != (None, None):
concept.startswith("c:") and \
(tmp := core.utils.unstr_concept(concept)) != (None, None):
concept = tmp
# ##############
@@ -567,7 +569,7 @@ class Sheerka(Concept):
# manage concept not found
if self.isinstance(template, BuiltinConcepts.UNKNOWN_CONCEPT) and \
concept_key != BuiltinConcepts.UNKNOWN_CONCEPT:
concept_key != BuiltinConcepts.UNKNOWN_CONCEPT:
return template
if isinstance(template, list):
@@ -791,7 +793,7 @@ class Sheerka(Concept):
Browse obj, looking for error
:param context:
:param obj:
:param kwargs: if defined, specialize the error
:param kwargs: if defined, specialize the error (example __type="PythonEvalError")
:return:
"""
@@ -834,6 +836,19 @@ class Sheerka(Concept):
errors = self.get_errors(context, obj, **kwargs)
return len(errors) > 0
def get_error_cause(self, obj):
if self.isinstance(obj, BuiltinConcepts.NOT_FOR_ME):
res = obj.reason
elif self.isinstance(obj, BuiltinConcepts.ERROR):
res = obj.body
else:
res = None
if isinstance(res, list) and len(res) == 1:
return res[0]
else:
return res
def get_evaluator_name(self, name):
if self.evaluators_prefix is None:
base_evaluator_class = core.utils.get_class("evaluators.BaseEvaluator.BaseEvaluator")