Added concepts with the same key handling

This commit is contained in:
2019-11-18 17:02:02 +01:00
parent 7fa509555d
commit cb6be9fec7
15 changed files with 255 additions and 43 deletions
+5 -2
View File
@@ -1,4 +1,5 @@
from core.builtin_concepts import BuiltinConcepts
from evaluators.AddConceptEvaluator import AddConceptEvaluator
from evaluators.BaseEvaluator import AllReturnValuesEvaluator
from parsers.BaseParser import BaseParser
@@ -8,8 +9,10 @@ class DuplicateConceptEvaluator(AllReturnValuesEvaluator):
Use to recognize when we tried to add the same concept twice
"""
NAME = "DuplicateConcept"
def __init__(self):
super().__init__("Duplicate Concept Evaluator", 10)
super().__init__(self.NAME, 10)
self.already_defined = None
def matches(self, context, return_values):
@@ -22,7 +25,7 @@ class DuplicateConceptEvaluator(AllReturnValuesEvaluator):
if sheerka.isinstance(ret.value, BuiltinConcepts.AFTER_EVALUATION):
if ret.status:
parsing = True
elif ret.who == "Evaluators:Add new Concept":
elif ret.who == sheerka.get_evaluator_name(AddConceptEvaluator.NAME):
if not ret.status and ret.value.body.args[0] == "Duplicate object.":
add_concept_in_error = True
self.already_defined = ret.value.body.obj