Add property-has-value example.
This commit is contained in:
parent
bbba6b75e1
commit
a99449c04a
@ -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 = {
|
knowledge_ingestion = {
|
||||||
"exists-property-with-value": exists_property_with_value,
|
"exists-property-with-value": exists_property_with_value,
|
||||||
"pertenence-to-group": pertenence_to_group,
|
"pertenence-to-group": pertenence_to_group,
|
||||||
"has-capacity": has_capacity,
|
"has-capacity": has_capacity,
|
||||||
"question": question,
|
"question": question,
|
||||||
"implies": implies,
|
"implies": implies,
|
||||||
|
"property-has-value": property_has_value,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -41,12 +41,14 @@ examples = [
|
|||||||
("implies", 'summer', 'hot')),
|
("implies", 'summer', 'hot')),
|
||||||
"answer": True,
|
"answer": True,
|
||||||
}),
|
}),
|
||||||
# {
|
('full_example',
|
||||||
# "text": "is chile in south america ?",
|
{
|
||||||
# "affirmation": "is chile in south america ?",
|
"text": "is chile in south america ?",
|
||||||
# "parsed": (),
|
"affirmation": "chile is in south america",
|
||||||
# "answer": None,
|
"parsed": ("question",
|
||||||
# },
|
("property-has-value", 'chile', 'location', 'south america')),
|
||||||
|
"answer": True,
|
||||||
|
}),
|
||||||
# {
|
# {
|
||||||
# "text": "Was Socrates a man?",
|
# "text": "Was Socrates a man?",
|
||||||
# "affirmation": "Was Socrates a man?",
|
# "affirmation": "Was Socrates a man?",
|
||||||
@ -641,6 +643,9 @@ base_knowledge = {
|
|||||||
'fly': {
|
'fly': {
|
||||||
"groups": {'verb'},
|
"groups": {'verb'},
|
||||||
},
|
},
|
||||||
|
'chile': {
|
||||||
|
"groups": {'noun'},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
Loading…
Reference in New Issue
Block a user