Add base test.
This commit is contained in:
parent
ad975015a6
commit
a94fd31af1
@ -60,7 +60,7 @@ class KnowledgeBase(object):
|
||||
knowledge_diff_getter = lambda: diff_knowledge(knowledge_before,
|
||||
knowledge_after)
|
||||
|
||||
return result, knowledge_diff_getter
|
||||
return result, inferred_tree, knowledge_diff_getter
|
||||
|
||||
def act_upon(self, result):
|
||||
if isinstance(result, ModifiableProperty):
|
||||
|
@ -7,14 +7,26 @@ examples = [
|
||||
"text": "icecream is cold",
|
||||
"parsed": ("exists-property-with-value", 'icecream', 'cold'),
|
||||
},
|
||||
{
|
||||
"text": "is icecream cold?",
|
||||
"parsed": ("question", ("exists-property-with-value", 'icecream', 'cold'))
|
||||
},
|
||||
{
|
||||
"text": "lava is dangerous",
|
||||
"parsed": ("exists-property-with-value", 'lava', 'dangerous')
|
||||
},
|
||||
{
|
||||
"text": "is lava dangerous?",
|
||||
"parsed": ("question", ("exists-property-with-value", 'lava', 'dangerous')),
|
||||
},
|
||||
{
|
||||
"text": "earth is a planet",
|
||||
"parsed": ("pertenence-to-group", 'earth', 'planet'),
|
||||
},
|
||||
{
|
||||
"text": "is earth a moon?",
|
||||
"parsed": ("question", ("pertenence-to-group", 'earth', 'moon')),
|
||||
},
|
||||
{
|
||||
"text": "Green is a color",
|
||||
"parsed": ("pertenence-to-group", 'green', 'color'),
|
||||
@ -26,7 +38,7 @@ examples = [
|
||||
{
|
||||
"text": "a wale can swim",
|
||||
"parsed": ("has-capacity", 'wale', 'swim')
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
base_knowledge = {
|
||||
@ -78,10 +90,7 @@ def test_assumption(expectedResponse, knowledge, query):
|
||||
print("Query: {}".format(query['text']))
|
||||
print("Expected: {}".format(expectedResponse))
|
||||
|
||||
import knowledge_evaluation
|
||||
result = knowledge_evaluation.integrate_information(
|
||||
knowledge.knowledge,
|
||||
query)
|
||||
result, abstract_tree, diff = knowledge.process(query['text'])
|
||||
print("\x1b[0;3{}mResult: {}\x1b[0m".format("1" if result != expectedResponse else "2", result))
|
||||
|
||||
|
||||
@ -97,7 +106,7 @@ def main():
|
||||
|
||||
for test in [{'text': 'a bus can run'}, {'text': 'io is a moon'}]:
|
||||
row = test['text']
|
||||
result, differences = knowledge.process(row)
|
||||
result, inferred_tree, differences = knowledge.process(row)
|
||||
|
||||
print("result:", result)
|
||||
print(differences())
|
||||
|
Loading…
Reference in New Issue
Block a user