mirror of
https://github.com/explosion/spaCy.git
synced 2025-05-29 10:13:19 +03:00
Display warning when spacy.explain() finds no term (#10645)
* Display warning when spacy.explain() finds no term * Updated warning message text
This commit is contained in:
parent
d4196a62f1
commit
75fbbcdc18
|
@ -196,6 +196,9 @@ class Warnings(metaclass=ErrorsWithCodes):
|
||||||
"surprising to you, make sure the Doc was processed using a model "
|
"surprising to you, make sure the Doc was processed using a model "
|
||||||
"that supports span categorization, and check the `doc.spans[spans_key]` "
|
"that supports span categorization, and check the `doc.spans[spans_key]` "
|
||||||
"property manually if necessary.")
|
"property manually if necessary.")
|
||||||
|
W118 = ("Term '{term}' not found in glossary. It may however be explained in documentation "
|
||||||
|
"for the corpora used to train the language. Please check "
|
||||||
|
"`nlp.meta[\"sources\"]` for any relevant links.")
|
||||||
|
|
||||||
|
|
||||||
class Errors(metaclass=ErrorsWithCodes):
|
class Errors(metaclass=ErrorsWithCodes):
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
import warnings
|
||||||
|
from .errors import Warnings
|
||||||
|
|
||||||
|
|
||||||
def explain(term):
|
def explain(term):
|
||||||
"""Get a description for a given POS tag, dependency label or entity type.
|
"""Get a description for a given POS tag, dependency label or entity type.
|
||||||
|
|
||||||
|
@ -11,6 +15,8 @@ def explain(term):
|
||||||
"""
|
"""
|
||||||
if term in GLOSSARY:
|
if term in GLOSSARY:
|
||||||
return GLOSSARY[term]
|
return GLOSSARY[term]
|
||||||
|
else:
|
||||||
|
warnings.warn(Warnings.W118.format(term=term))
|
||||||
|
|
||||||
|
|
||||||
GLOSSARY = {
|
GLOSSARY = {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user