Convert the linear exploration into a more tree-like.
This commit is contained in:
parent
ae8d717344
commit
393527590c
5 changed files with 120 additions and 166 deletions
|
@ -1,4 +1,8 @@
|
|||
from modifiable_property import ModifiableProperty
|
||||
from modifiable_property import (
|
||||
ModifiableProperty,
|
||||
ModifiablePropertyWithAst,
|
||||
is_modifiable_property,
|
||||
)
|
||||
|
||||
|
||||
def resolve(knowledge_base, elements, value):
|
||||
|
@ -122,7 +126,7 @@ def has_capacity(knowledge_base, elements, subj, capacity):
|
|||
def question(knowledge_base, elements, subj):
|
||||
subj = resolve(knowledge_base, elements, subj)
|
||||
|
||||
if isinstance(subj, ModifiableProperty):
|
||||
if is_modifiable_property(subj):
|
||||
return subj.getter()
|
||||
return subj
|
||||
|
||||
|
@ -135,9 +139,21 @@ knowledge_ingestion = {
|
|||
}
|
||||
|
||||
|
||||
def tagged_with_ast(ast, elements, modifiable_property):
|
||||
if not isinstance(modifiable_property, ModifiableProperty):
|
||||
return modifiable_property
|
||||
|
||||
return ModifiablePropertyWithAst(modifiable_property.getter,
|
||||
modifiable_property.setter,
|
||||
ast, elements)
|
||||
|
||||
|
||||
def integrate_information(knowledge_base, example):
|
||||
method = example['parsed'][0]
|
||||
args = example['parsed'][1:]
|
||||
ast = example['parsed']
|
||||
method = ast[0]
|
||||
args = ast[1:]
|
||||
elements = example.get('elements', None)
|
||||
|
||||
return knowledge_ingestion[method](knowledge_base, elements, *args)
|
||||
return tagged_with_ast(
|
||||
ast, elements,
|
||||
knowledge_ingestion[method](knowledge_base, elements, *args))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue