Fixed parsing of BNF concepts mixed with isaset concepts

This commit is contained in:
2020-07-02 16:32:02 +02:00
parent 2c5840752a
commit f26c391d3f
12 changed files with 413 additions and 123 deletions
@@ -3,7 +3,7 @@ from cache.Cache import Cache
from cache.SetCache import SetCache
from core.ast.nodes import python_to_concept
from core.builtin_concepts import BuiltinConcepts
from core.concept import Concept, ConceptParts, ensure_concept
from core.concept import Concept, ConceptParts, ensure_concept, DEFINITION_TYPE_BNF
from core.sheerka.services.sheerka_service import BaseService
GROUP_PREFIX = 'All_'
@@ -145,10 +145,13 @@ class SheerkaSetsManager(BaseService):
return concepts
# already in cache ?
if res := self.concepts_in_set.get(concept.id):
return res
res = _get_set_elements(concept)
# put in cache
self.concepts_in_set.put(concept.id, res)
return res
@@ -196,6 +199,11 @@ class SheerkaSetsManager(BaseService):
if not (isinstance(concept, Concept) and concept.id):
return False
# KSI 29062020
# To resolve infinite recursion between group concepts and BNF concepts
if concept.metadata.definition_type == DEFINITION_TYPE_BNF:
return False
# check if it has a group
# TODO: use cache instead of directly requesting sdp
if self.sets.get(concept.id):
@@ -255,7 +263,8 @@ for x in xx__concepts__xx:
for element_id in ids:
concept = self.sheerka.get_by_id(element_id)
if len(concept.metadata.variables) == 0:
# only evaluate
# The concepts are directly taken from Sheerka.get_by_id, so variable cannot be filled
# It's the reason why we only evaluate concept with no variable
evaluated = self.sheerka.evaluate_concept(sub_context, concept)
if context.sheerka.is_success(evaluated):
result.append(evaluated)