From 8e822b50fc2ccaa0dc4476b5c82b78f997c1d388 Mon Sep 17 00:00:00 2001 From: ines Date: Fri, 9 Mar 2018 13:36:36 +0100 Subject: [PATCH] Print warning if doc is not parsed/tagged (see #2066) --- spacy/displacy/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spacy/displacy/__init__.py b/spacy/displacy/__init__.py index c75c5632c..15d67fc90 100644 --- a/spacy/displacy/__init__.py +++ b/spacy/displacy/__init__.py @@ -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