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