Concept validation must be requested

This commit is contained in:
2020-03-09 12:23:53 +01:00
parent ef31a4807d
commit 1bde97b5e3
27 changed files with 346 additions and 280 deletions
+2 -19
View File
@@ -90,27 +90,12 @@ class SheerkaExecute:
result = core.utils.remove_list_from_list(result, user_inputs)
return result
def call_evaluators(self, execution_context, return_values, process_step, evaluation_context=None):
def call_evaluators(self, execution_context, return_values, process_step):
# return_values must be a list
if not isinstance(return_values, list):
return_values = [return_values]
# Evaluation context are contexts that may modify the behaviour of the execution
# For example, a concept to indicate that the value is not wanted
# Or a concept to indicate that we want the letter form of the response
# But first, they need to be transformed into return values
if evaluation_context is None:
evaluation_return_values = []
else:
evaluation_return_values = [self.sheerka.ret(execution_context.who, True, c) for c in evaluation_context]
# add the current step as part as the evaluation context
evaluation_return_values.append(self.sheerka.ret(execution_context.who, True, self.sheerka.new(process_step)))
# the pool of return values are the mix
return_values.extend(evaluation_return_values)
# group the evaluators by priority and sort them
# The first one to be applied will be the one with the highest priority
grouped_evaluators = {}
@@ -203,8 +188,6 @@ class SheerkaExecute:
# inc the iteration and continue
iteration += 1
# remove all evaluation context that are not reduced
return_values = core.utils.remove_list_from_list(return_values, evaluation_return_values)
return return_values
def execute(self, execution_context, return_values, execution_steps):
@@ -223,7 +206,7 @@ class SheerkaExecute:
if step == BuiltinConcepts.PARSING:
return_values = self.call_parsers(sub_context, return_values)
else:
return_values = self.call_evaluators(sub_context, return_values, step, None)
return_values = self.call_evaluators(sub_context, return_values, step)
if copy != return_values:
sub_context.log_result(return_values)