Only get user_data if it exists on doc

This commit is contained in:
ines 2017-05-15 13:39:47 +02:00
parent 6d7986b7bc
commit 98354be150
1 changed files with 1 additions and 1 deletions

View File

@ -99,5 +99,5 @@ def parse_ents(doc, options={}):
""" """
ents = [{'start': ent.start_char, 'end': ent.end_char, 'label': ent.label_} ents = [{'start': ent.start_char, 'end': ent.end_char, 'label': ent.label_}
for ent in doc.ents] for ent in doc.ents]
title = doc.user_data.get('title', None) title = doc.user_data.get('title', None) if hasattr(doc, 'user_data') else None
return {'text': doc.text, 'ents': ents, 'title': title} return {'text': doc.text, 'ents': ents, 'title': title}