Setup an structure to allow setting or getting elements.
This commit is contained in:
parent
e42ef8f415
commit
675a494723
3 changed files with 70 additions and 12 deletions
|
@ -2,6 +2,7 @@ import copy
|
|||
|
||||
import parsing
|
||||
import knowledge_evaluation
|
||||
from modifiable_property import ModifiableProperty
|
||||
|
||||
|
||||
def diff_knowledge(before, after):
|
||||
|
@ -23,11 +24,12 @@ class KnowledgeBase(object):
|
|||
for example in examples:
|
||||
tokens, decomposition, inferred_tree = parsing.integrate_language(self, example)
|
||||
print(tokens)
|
||||
knowledge_evaluation.integrate_information(self.knowledge, {
|
||||
result = knowledge_evaluation.integrate_information(self.knowledge, {
|
||||
"elements": tokens,
|
||||
"decomposition": decomposition,
|
||||
"parsed": inferred_tree,
|
||||
})
|
||||
self.act_upon(result)
|
||||
parsed_examples.append((decomposition, inferred_tree))
|
||||
|
||||
# Reduce values
|
||||
|
@ -52,8 +54,16 @@ class KnowledgeBase(object):
|
|||
"decomposition": decomposition,
|
||||
"parsed": inferred_tree,
|
||||
})
|
||||
self.act_upon(result)
|
||||
|
||||
knowledge_after = copy.deepcopy(self.knowledge)
|
||||
knowledge_diff_getter = lambda: diff_knowledge(knowledge_before,
|
||||
knowledge_after)
|
||||
|
||||
return result, knowledge_diff_getter
|
||||
|
||||
def act_upon(self, result):
|
||||
if isinstance(result, ModifiableProperty):
|
||||
result.setter()
|
||||
else:
|
||||
print(result)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue