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
+14 -4
View File
@@ -2,6 +2,7 @@ from dataclasses import dataclass
from core import builtin_helpers
from core.builtin_concepts import BuiltinConcepts
from core.builtin_helpers import update_concepts_hints
from core.concept import DEFINITION_TYPE_BNF, Concept
from core.sheerka.services.SheerkaExecute import ParserInput
from core.tokenizer import Tokenizer, TokenKind
@@ -230,7 +231,8 @@ class SequenceNodeParser(BaseNodeParser):
:param concept:
:return:
"""
return len(concept.get_metadata().variables) == 0 and concept.get_metadata().definition_type != DEFINITION_TYPE_BNF
return len(concept.get_metadata().variables) == 0 \
and concept.get_metadata().definition_type != DEFINITION_TYPE_BNF
def get_concepts(self, token, to_keep, custom=None, to_map=None, strip_quotes=False):
@@ -245,11 +247,11 @@ class SequenceNodeParser(BaseNodeParser):
def as_list(a):
if a is None:
return a
return None
return a if isinstance(a, list) else [a]
concepts_by_name = as_list(self.sheerka.resolve(token))
concepts_by_name = as_list(self.sheerka.fast_resolve(token))
concepts_by_first_keyword = new_instances(self.sheerka.get_concepts_by_first_token(token, self._is_eligible))
if concepts_by_name is None:
@@ -339,11 +341,17 @@ class SequenceNodeParser(BaseNodeParser):
It will use the name of the concept, but also its compact form (c::)
:return:
"""
source = self.parser_input.as_text()
concepts = self.sheerka.resolve(source.strip())
concepts = self.sheerka.fast_resolve(source.strip())
if concepts is None:
return None
update_concepts_hints(concepts,
# recognized_by=RECOGNIZED_BY_NAME, # keep fast_resolve settings
is_instance=False,
is_evaluated=True)
concepts = [concepts] if isinstance(concepts, Concept) else concepts
res = []
start, end = self.get_tokens_boundaries(self.parser_input.as_tokens())
@@ -414,6 +422,8 @@ class SequenceNodeParser(BaseNodeParser):
sequences = self.get_concepts_sequences()
if by_name := self.get_by_name():
# note that concepts by names must be appended, not prepended
# In case of conflict, we want to keep the one found by get_concepts_sequences()
sequences.extend(by_name)
parser_helpers = self.get_valid(sequences)