Remove need from as_property
info.
Probably this can be improved upon if the data is later analyzed with it's similars.
This commit is contained in:
parent
d6628101de
commit
6693b7deb0
@ -49,6 +49,7 @@ class KnowledgeBase(object):
|
|||||||
|
|
||||||
|
|
||||||
def process(self, row):
|
def process(self, row):
|
||||||
|
row = row.lower()
|
||||||
knowledge_before = copy.deepcopy(self.knowledge)
|
knowledge_before = copy.deepcopy(self.knowledge)
|
||||||
logging.info("\x1b[7;32m> {} \x1b[0m".format(row))
|
logging.info("\x1b[7;32m> {} \x1b[0m".format(row))
|
||||||
tokens = parsing.to_tokens(row)
|
tokens = parsing.to_tokens(row)
|
||||||
|
@ -41,17 +41,32 @@ def get_subquery_type(knowledge_base, atom):
|
|||||||
|
|
||||||
|
|
||||||
def property_for_value(knowledge_base, value):
|
def property_for_value(knowledge_base, value):
|
||||||
return knowledge_base[value]['as_property']
|
if 'as_property' in knowledge_base[value]:
|
||||||
|
return knowledge_base[value]['as_property']
|
||||||
|
|
||||||
|
return knowledge_base[value].get('groups', set(['noun']))
|
||||||
|
|
||||||
|
|
||||||
def modifiable_property_from_property(prop, path, value):
|
def modifiable_property_from_property(prop, path, value):
|
||||||
def getter():
|
def getter():
|
||||||
nonlocal prop, path, value
|
nonlocal prop, path, value
|
||||||
return (path in prop) and prop[path] == value
|
if isinstance(path, set):
|
||||||
|
# If the property is from a set, it's true if any possible
|
||||||
|
# path has a element as true
|
||||||
|
return any(map(lambda possible_path: ((possible_path in prop)
|
||||||
|
and
|
||||||
|
(prop[possible_path] == value)),
|
||||||
|
path))
|
||||||
|
else:
|
||||||
|
return (path in prop) and prop[path] == value
|
||||||
|
|
||||||
def setter():
|
def setter():
|
||||||
nonlocal prop, path, value
|
nonlocal prop, path, value
|
||||||
prop[path] = value
|
if isinstance(path, set):
|
||||||
|
for possible_path in path:
|
||||||
|
prop[possible_path] = value
|
||||||
|
else:
|
||||||
|
prop[path] = value
|
||||||
|
|
||||||
return ModifiableProperty(
|
return ModifiableProperty(
|
||||||
getter=getter,
|
getter=getter,
|
||||||
|
Loading…
Reference in New Issue
Block a user