Fix subquery learning/interpretation.
This commit is contained in:
parent
e83725efa4
commit
b2b6be6c9a
@ -6,6 +6,7 @@ import re
|
||||
import copy
|
||||
from functools import reduce
|
||||
from typing import List
|
||||
from modifiable_property import ModifiableProperty
|
||||
|
||||
MAX_RECURSIONS = 5
|
||||
|
||||
@ -110,11 +111,11 @@ def integrate_language(knowledge_base, example):
|
||||
new_tokens.insert(offset, (subquery_type, remix))
|
||||
tokens = new_tokens
|
||||
|
||||
resolved_parsed = replace_position(resolved_parsed, position, subquery_type)
|
||||
resolved_parsed = replace_position(resolved_parsed, position, offset)
|
||||
print("#########")
|
||||
|
||||
|
||||
tokens, matcher, result = make_template(knowledge_base, tokens, parsed)
|
||||
tokens, matcher, result = make_template(knowledge_base, tokens, resolved_parsed)
|
||||
print("T:", tokens)
|
||||
print("M:", matcher)
|
||||
print("R:", result)
|
||||
@ -357,7 +358,11 @@ def fitting_return_type(knowledge,
|
||||
remaining_output + tail_of_ouput_stream,
|
||||
"\x1b[0m")
|
||||
print()
|
||||
yield (parsed_input,
|
||||
resolved_input = knowledge_evaluation.resolve(knowledge.knowledge,
|
||||
parsed_input, ast)
|
||||
if isinstance(resolved_input, ModifiableProperty):
|
||||
resolved_input = resolved_input.getter()
|
||||
yield ([resolved_input],
|
||||
(remaining_input, remaining_output + tail_of_ouput_stream))
|
||||
except TypeError as e:
|
||||
print(indent + "X " + str(e))
|
||||
@ -368,6 +373,9 @@ def fitting_return_type(knowledge,
|
||||
except IndexError as e:
|
||||
print(indent + "X " + str(e))
|
||||
pass
|
||||
except KeyError as e:
|
||||
print(indent + "X " + str(e))
|
||||
pass
|
||||
raise TypeError("No matching type found")
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user