Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
erickpeirson committed May 23, 2017
1 parent 9221bb5 commit f4da75f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions annotations/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,21 @@ def generate_expression(template, relations):
expression_keys = [k[1].replace('_', '') for k in Formatter().parse(template.expression)
if k[1] is not None]
expression_data = {}
print expression_keys
print relations
for key in expression_keys:
try:
relation = relations[int(key[0])]
attr_name = PRED_MAP.get(key[1])
value = expression_partial(getattr(relation, attr_name))
except ValueError:
return ''
value = '[missing]'
except KeyError:
value = '[missing]'
if not attr_name:
continue
obj = getattr(relation, attr_name)
expression_data[key] = expression_partial(obj)

expression_data[key] = value
return template.expression.replace('_', '').format(**expression_data)


Expand All @@ -345,7 +350,10 @@ def get_terminal_nodes(template, relations):
return nodes

for key in template.terminal_nodes.split(','):
obj = getattr(relations[int(key[0])], PRED_MAP.get(key[1]))
try:
obj = getattr(relations[int(key[0])], PRED_MAP.get(key[1]))
except KeyError:
continue
if hasattr(obj, 'interpretation') and obj.interpretation:
nodes.append(obj.interpretation)
return nodes
Expand Down
2 changes: 1 addition & 1 deletion annotations/static/annotations/js/annotators/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,7 @@ RelationTemplateSelector = {
search: function() {
this.searching = true;
self = this;
RelationTemplateResource.query({search: this.query, format: "json"}).then(function(response) {
RelationTemplateResource.query({search: this.query, format: "json", all: true}).then(function(response) {
self.templates = response.body.templates;
self.searching = false;
}).catch(function(error) {
Expand Down

0 comments on commit f4da75f

Please sign in to comment.