Add session context, increase logging.
This commit is contained in:
parent
359f858c39
commit
bb7d438e0d
7 changed files with 103 additions and 77 deletions
|
@ -125,7 +125,9 @@ def main():
|
|||
knowledge=base_knowledge,
|
||||
)
|
||||
|
||||
differences = knowledge.train(examples)
|
||||
for example in examples:
|
||||
with session().log(example['text']):
|
||||
differences = knowledge.train([example])
|
||||
|
||||
session().annotate("----")
|
||||
session().annotate(differences())
|
||||
|
|
|
@ -696,19 +696,20 @@ def main():
|
|||
|
||||
for i, (example_type, data) in enumerate(examples):
|
||||
if example_type == 'full_example':
|
||||
session().log_step(data['affirmation'], 0)
|
||||
affirmation = {
|
||||
'text': data['affirmation'],
|
||||
'parsed': data['parsed'][1],
|
||||
}
|
||||
question = data
|
||||
|
||||
show_progbar(i, total, data['affirmation'])
|
||||
differences = knowledge.train([affirmation])
|
||||
with session().log(data['affirmation']):
|
||||
show_progbar(i, total, data['affirmation'])
|
||||
differences = knowledge.train([affirmation])
|
||||
|
||||
show_progbar(i, total, data['text'])
|
||||
differences = knowledge.train([question])
|
||||
session().annotate(differences())
|
||||
with session().log(data['text']):
|
||||
show_progbar(i, total, data['text'])
|
||||
differences = knowledge.train([question])
|
||||
session().annotate(differences())
|
||||
|
||||
result, _, _ = knowledge.process(data['text'])
|
||||
|
||||
|
@ -720,20 +721,20 @@ def main():
|
|||
raise AssertionError('{} is not {}'.format(result, data['answer']))
|
||||
|
||||
elif example_type == 'text_example':
|
||||
session().log_step(data['affirmation'], 0)
|
||||
with session().log(data['affirmation']):
|
||||
show_progbar(i, total, data['affirmation'])
|
||||
affirmation = data['affirmation']
|
||||
session().annotate("Processing affirmation: {}".format(affirmation))
|
||||
_, _, _ = knowledge.process(affirmation)
|
||||
|
||||
show_progbar(i, total, data['affirmation'])
|
||||
affirmation = data['affirmation']
|
||||
session().annotate("Processing affirmation: {}".format(affirmation))
|
||||
_, _, _ = knowledge.process(affirmation)
|
||||
with session().log(data['question']):
|
||||
show_progbar(i, total, data['question'])
|
||||
question = data['question']
|
||||
session().annotate("Processing question : {}".format(question))
|
||||
result, _, _ = knowledge.process(question)
|
||||
|
||||
show_progbar(i, total, data['question'])
|
||||
question = data['question']
|
||||
session().annotate("Processing question : {}".format(question))
|
||||
result, _, _ = knowledge.process(question)
|
||||
|
||||
if result != data['answer']:
|
||||
raise AssertionError('{} is not {}'.format(result, data['answer']))
|
||||
if result != data['answer']:
|
||||
raise AssertionError('{} is not {}'.format(result, data['answer']))
|
||||
|
||||
else:
|
||||
raise NotImplementedError('Example type: {}'.format(example_type))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue