Blindly replace all prints by logging.debug.
Also, add a "depth" meter to measure the depth level in the tree matching.
This commit is contained in:
parent
b2b6be6c9a
commit
851ab1de20
5 changed files with 117 additions and 105 deletions
|
@ -1,5 +1,6 @@
|
|||
import copy
|
||||
|
||||
import logging
|
||||
import parsing
|
||||
import knowledge_evaluation
|
||||
from modifiable_property import ModifiableProperty
|
||||
|
@ -22,18 +23,18 @@ class KnowledgeBase(object):
|
|||
# Parse everything
|
||||
parsed_examples = []
|
||||
for example in examples:
|
||||
print("\x1b[7;32m> {} \x1b[0m".format(example))
|
||||
logging.debug("\x1b[7;32m> {} \x1b[0m".format(example))
|
||||
tokens, decomposition, inferred_tree = parsing.integrate_language(self, example)
|
||||
print(tokens)
|
||||
logging.debug(tokens)
|
||||
result = knowledge_evaluation.integrate_information(self.knowledge, {
|
||||
"elements": tokens,
|
||||
"decomposition": decomposition,
|
||||
"parsed": inferred_tree,
|
||||
})
|
||||
|
||||
print("\x1b[7;33m< {} \x1b[0m".format(self.get_value(result)))
|
||||
logging.debug("\x1b[7;33m< {} \x1b[0m".format(self.get_value(result)))
|
||||
self.act_upon(result)
|
||||
print("\x1b[7;34m< {} \x1b[0m".format(self.get_value(result)))
|
||||
logging.debug("\x1b[7;34m> set: {} \x1b[0m".format(self.get_value(result)))
|
||||
self.examples.append((decomposition, inferred_tree))
|
||||
|
||||
# Reduce values
|
||||
|
@ -48,7 +49,7 @@ class KnowledgeBase(object):
|
|||
|
||||
def process(self, row):
|
||||
knowledge_before = copy.deepcopy(self.knowledge)
|
||||
print("\x1b[7;32m> {} \x1b[0m".format(row))
|
||||
logging.debug("\x1b[7;32m> {} \x1b[0m".format(row))
|
||||
tokens, inferred_tree = parsing.get_fit(self, row)
|
||||
result = knowledge_evaluation.integrate_information(self.knowledge,
|
||||
{
|
||||
|
@ -73,4 +74,4 @@ class KnowledgeBase(object):
|
|||
if isinstance(result, ModifiableProperty):
|
||||
result.setter()
|
||||
else:
|
||||
print(result)
|
||||
logging.debug(result)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue