Refactored to allow ConceptEvaluator
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
from core.concept import Concept, ConceptParts
|
||||
from evaluators.BaseEvaluator import OneReturnValueEvaluator
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ConceptEvaluator(OneReturnValueEvaluator):
|
||||
def __init__(self):
|
||||
super().__init__("Concept Evaluator", 50)
|
||||
|
||||
def matches(self, context, return_value):
|
||||
return return_value.status and \
|
||||
return_value.who == "Parsers:ConceptParser" and \
|
||||
isinstance(return_value.value, Concept)
|
||||
|
||||
def eval(self, context, return_value):
|
||||
sheerka = context.sheerka
|
||||
concept = return_value.value
|
||||
|
||||
# pre condition should already be validated by the parser.
|
||||
# It's a mandatory condition for the concept before it can be recognized
|
||||
|
||||
if len(concept.codes) == 0:
|
||||
sheerka.add_codes_to_concept(context, concept)
|
||||
|
||||
# TODO; check pre
|
||||
# if pre is not true, return Concept with a false value
|
||||
|
||||
body = concept.codes[ConceptParts.BODY]
|
||||
if body is None:
|
||||
return None # nothing to do
|
||||
|
||||
return sheerka.ret(self.name, True, body.value, parents=[return_value])
|
||||
|
||||
Reference in New Issue
Block a user