Implemented SheerkaOntology
This commit is contained in:
@@ -126,15 +126,15 @@ class SyaConceptDef:
|
||||
|
||||
# first, try to look in the parser
|
||||
# it is where to find the data during the unit tests
|
||||
if parser and concept.id in parser.sya_definitions:
|
||||
if parser and concept.id in parser.test_only_sya_definitions:
|
||||
# Manage when precedence and associativity are given in the unit tests
|
||||
sya_def = parser.sya_definitions.get(concept.id)
|
||||
sya_def = parser.test_only_sya_definitions.get(concept.id)
|
||||
if sya_def[0] is not None:
|
||||
sya_concept_def.precedence = sya_def[0]
|
||||
if sya_def[1] is not None:
|
||||
sya_concept_def.associativity = sya_def[1]
|
||||
|
||||
# otherwise, use sheerka
|
||||
# otherwise, use sheerka # KSI 20210109 otherwise or override ??
|
||||
if sheerka:
|
||||
concept_weight = parser.sheerka.get_concepts_weights(BuiltinConcepts.PRECEDENCE, CONCEPT_COMPARISON_CONTEXT)
|
||||
if concept.str_id in concept_weight:
|
||||
@@ -332,7 +332,7 @@ class InFixToPostFix:
|
||||
def _add_debug(self, debug_info: DebugInfo):
|
||||
if debug_info.level is None or (self.enabled_debug_levels and
|
||||
(f"#{self.id}.{debug_info.level}" in self.enabled_debug_levels or
|
||||
"*" in self.enabled_debug_levels)):
|
||||
"*" in self.enabled_debug_levels)):
|
||||
self.debug.append(debug_info)
|
||||
|
||||
def _is_lpar(self, token):
|
||||
@@ -1134,20 +1134,14 @@ class SyaNodeParser(BaseNodeParser):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(SyaNodeParser.NAME, 50, **kwargs)
|
||||
if 'sheerka' in kwargs:
|
||||
sheerka = kwargs.get("sheerka")
|
||||
self.sya_definitions = sheerka.resolved_sya_def
|
||||
|
||||
else:
|
||||
self.concepts_by_first_keyword = {}
|
||||
self.sya_definitions = {}
|
||||
self.test_only_sya_definitions = {}
|
||||
|
||||
def init_from_concepts(self, context, concepts, **kwargs):
|
||||
super().init_from_concepts(context, concepts)
|
||||
|
||||
sya_definitions = kwargs.get("sya", None)
|
||||
if sya_definitions:
|
||||
self.sya_definitions = sya_definitions
|
||||
self.test_only_sya_definitions = sya_definitions
|
||||
|
||||
@staticmethod
|
||||
def _is_eligible(concept):
|
||||
@@ -1431,10 +1425,3 @@ class SyaNodeParser(BaseNodeParser):
|
||||
result.append(infix_to_postfix)
|
||||
|
||||
return result
|
||||
|
||||
# @staticmethod
|
||||
# def init_sheerka(self, sheerka):
|
||||
# if hasattr(BaseNodeParser, "init_sheerka"):
|
||||
# BaseNodeParser.init_sheerka(sheerka)
|
||||
#
|
||||
# # init syadefinitins
|
||||
|
||||
Reference in New Issue
Block a user