Implication example.
This commit is contained in:
parent
22534160c9
commit
d029ecd91d
@ -154,12 +154,29 @@ def question(knowledge_base, elements, subj):
|
|||||||
return subj.getter()
|
return subj.getter()
|
||||||
return subj
|
return subj
|
||||||
|
|
||||||
|
def implies(knowledge_base, elements, precedent, consequent):
|
||||||
|
precedent = resolve(knowledge_base, elements, precedent)
|
||||||
|
consequent = resolve(knowledge_base, elements, consequent)
|
||||||
|
|
||||||
|
if precedent not in knowledge_base:
|
||||||
|
knowledge_base[precedent] = {}
|
||||||
|
|
||||||
|
if "implications" not in knowledge_base[precedent]:
|
||||||
|
knowledge_base[precedent]["implications"] = set()
|
||||||
|
|
||||||
|
return modifiable_element_for_existance_in_set(
|
||||||
|
container=knowledge_base[precedent],
|
||||||
|
set_name="implications",
|
||||||
|
element=consequent
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
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,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,12 +33,14 @@ examples = [
|
|||||||
("has-capacity", 'plane', 'fly')),
|
("has-capacity", 'plane', 'fly')),
|
||||||
"answer": True,
|
"answer": True,
|
||||||
}),
|
}),
|
||||||
# {
|
('full_example',
|
||||||
# "text": "Is it hot during the summer?",
|
{
|
||||||
# "affirmation": "Is it hot during the summer?",
|
"text": "Is it hot during the summer?",
|
||||||
# "parsed": (),
|
"affirmation": "it is hot during the summer",
|
||||||
# "answer": None,
|
"parsed": ("question",
|
||||||
# },
|
("implies", 'summer', 'hot')),
|
||||||
|
"answer": True,
|
||||||
|
}),
|
||||||
# {
|
# {
|
||||||
# "text": "is chile in south america ?",
|
# "text": "is chile in south america ?",
|
||||||
# "affirmation": "is chile in south america ?",
|
# "affirmation": "is chile in south america ?",
|
||||||
@ -618,6 +620,12 @@ base_knowledge = {
|
|||||||
'cold': {
|
'cold': {
|
||||||
"groups": {'property', 'temperature'},
|
"groups": {'property', 'temperature'},
|
||||||
},
|
},
|
||||||
|
'hot': {
|
||||||
|
"groups": {'property', 'temperature'},
|
||||||
|
},
|
||||||
|
'summer': {
|
||||||
|
"groups": {'epoch'},
|
||||||
|
},
|
||||||
'earth': {
|
'earth': {
|
||||||
"groups": {'noun', 'object', 'planet'},
|
"groups": {'noun', 'object', 'planet'},
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user