Add property-has-value example.

This commit is contained in:
kenkeiras 2017-05-24 20:42:15 +02:00
parent bbba6b75e1
commit a99449c04a
2 changed files with 30 additions and 6 deletions

View File

@ -171,12 +171,31 @@ def implies(knowledge_base, elements, precedent, consequent):
)
def property_has_value(knowledge_base, elements, subj, prop, value):
subj = resolve(knowledge_base, elements, subj)
prop = resolve(knowledge_base, elements, prop)
value = resolve(knowledge_base, elements, value)
if subj not in knowledge_base:
knowledge_base[subj] = {}
if prop not in knowledge_base[subj]:
knowledge_base[subj][prop] = set()
return modifiable_element_for_existance_in_set(
container=knowledge_base[subj],
set_name=prop,
element=value
)
knowledge_ingestion = {
"exists-property-with-value": exists_property_with_value,
"pertenence-to-group": pertenence_to_group,
"has-capacity": has_capacity,
"question": question,
"implies": implies,
"property-has-value": property_has_value,
}

View File

@ -41,12 +41,14 @@ examples = [
("implies", 'summer', 'hot')),
"answer": True,
}),
# {
# "text": "is chile in south america ?",
# "affirmation": "is chile in south america ?",
# "parsed": (),
# "answer": None,
# },
('full_example',
{
"text": "is chile in south america ?",
"affirmation": "chile is in south america",
"parsed": ("question",
("property-has-value", 'chile', 'location', 'south america')),
"answer": True,
}),
# {
# "text": "Was Socrates a man?",
# "affirmation": "Was Socrates a man?",
@ -641,6 +643,9 @@ base_knowledge = {
'fly': {
"groups": {'verb'},
},
'chile': {
"groups": {'noun'},
}
}
def main():