Print warning if doc is not parsed/tagged (see #2066)

This commit is contained in:
ines 2018-03-09 13:36:36 +01:00
parent 7e80550f13
commit 8e822b50fc

View File

@ -30,6 +30,12 @@ def render(docs, style='dep', page=False, minify=False, jupyter=IS_JUPYTER,
raise ValueError("Unknown style: %s" % style)
if isinstance(docs, Doc) or isinstance(docs, dict):
docs = [docs]
if style == 'dep' and any(not doc.is_parsed or not doc.is_tagged
for doc in docs):
print("Warning: One or more documents you're trying to visualize "
"don't seem to be tagged and/or parsed. Make sure the nlp "
"object you're using has a model with a tagger and dependency "
"parser loaded.")
renderer, converter = factories[style]
renderer = renderer(options=options)
parsed = [converter(doc, options) for doc in docs] if not manual else docs