Integrate the knowledge ASAP.

If we do this before the parsing we can leverage that semantics
in the matching phase.
This commit is contained in:
kenkeiras 2017-05-24 22:02:32 +02:00
parent 02f909269a
commit 2bfe676b2d
2 changed files with 17 additions and 5 deletions

View File

@ -24,6 +24,13 @@ class KnowledgeBase(object):
# Parse everything
parsed_examples = []
for example in examples:
# If there's parsed data, leverage it ASAP
if 'parsed' in example:
result = knowledge_evaluation.integrate_information(self.knowledge, {
"parsed": example['parsed'],
})
self.act_upon(result)
logging.info("\x1b[7;32m> {} \x1b[0m".format(example))
tokens, decomposition, inferred_tree = parsing.integrate_language(self, example)
logging.info(tokens)

View File

@ -123,12 +123,17 @@ def pertenence_to_group(knowledge_base, elements, subj, group):
if "groups" not in knowledge_base[subj]:
knowledge_base[subj]["groups"] = set()
return modifiable_element_for_existance_in_set(
container=knowledge_base[subj],
set_name="groups",
element=group
)
if group not in knowledge_base:
knowledge_base[group] = {}
if "groups" not in knowledge_base[group]:
knowledge_base[group]["groups"] = set()
return modifiable_element_for_existance_in_group(
container=knowledge_base[subj],
element=group,
backlink=knowledge_base[group],
)
def has_capacity(knowledge_base, elements, subj, capacity):
subj = resolve(knowledge_base, elements, subj)