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
|
||||
|
||||
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 = {
|
||||
"exists-property-with-value": exists_property_with_value,
|
||||
"pertenence-to-group": pertenence_to_group,
|
||||
"has-capacity": has_capacity,
|
||||
"question": question,
|
||||
"implies": implies,
|
||||
}
|
||||
|
||||
|
||||
|
@ -33,12 +33,14 @@ examples = [
|
||||
("has-capacity", 'plane', 'fly')),
|
||||
"answer": True,
|
||||
}),
|
||||
# {
|
||||
# "text": "Is it hot during the summer?",
|
||||
# "affirmation": "Is it hot during the summer?",
|
||||
# "parsed": (),
|
||||
# "answer": None,
|
||||
# },
|
||||
('full_example',
|
||||
{
|
||||
"text": "Is it hot during the summer?",
|
||||
"affirmation": "it is hot during the summer",
|
||||
"parsed": ("question",
|
||||
("implies", 'summer', 'hot')),
|
||||
"answer": True,
|
||||
}),
|
||||
# {
|
||||
# "text": "is chile in south america ?",
|
||||
# "affirmation": "is chile in south america ?",
|
||||
@ -618,6 +620,12 @@ base_knowledge = {
|
||||
'cold': {
|
||||
"groups": {'property', 'temperature'},
|
||||
},
|
||||
'hot': {
|
||||
"groups": {'property', 'temperature'},
|
||||
},
|
||||
'summer': {
|
||||
"groups": {'epoch'},
|
||||
},
|
||||
'earth': {
|
||||
"groups": {'noun', 'object', 'planet'},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user