Skip to content

Commit

Permalink
field in the guard can be knowledge_graph or in the doc
Browse files Browse the repository at this point in the history
  • Loading branch information
saggu committed Jan 19, 2018
1 parent def011f commit 4bbabf1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions etk/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,11 +725,9 @@ def process_kg_enchancement_guards(self, doc, guards):
result = True
for guard in guards:
if _FIELD in guard:
if guard[_FIELD] == _URL and _URL in doc:
result &= self.process_one_guard(doc[_URL], guard)
else:
kg_field = guard[_FIELD]
kg_values = doc[_KNOWLEDGE_GRAPH][kg_field] if kg_field in doc[_KNOWLEDGE_GRAPH] else None
g_field = guard[_FIELD]
if g_field in doc[_KNOWLEDGE_GRAPH]:
kg_values = doc[_KNOWLEDGE_GRAPH][g_field] if g_field in doc[_KNOWLEDGE_GRAPH] else None
if not kg_values:
return False

Expand All @@ -739,6 +737,10 @@ def process_kg_enchancement_guards(self, doc, guards):
except:
values = [v[_VALUE] for v in kg_values]
result &= self.process_one_guard(values, guard)
elif g_field in doc:
result &= self.process_one_guard(doc[g_field], guard)
else:
return False
if not result:
break
return result
Expand Down

0 comments on commit 4bbabf1

Please sign in to comment.