diff --git a/spacy/util.py b/spacy/util.py index 3fbd22aaf..460954b8f 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -11,6 +11,8 @@ import sys import textwrap import random from collections import OrderedDict +import inspect +import warnings from thinc.neural._classes.model import Model import functools @@ -501,6 +503,18 @@ def from_disk(path, readers, exclude): return path +def deprecated(message, filter='always'): + """Show a deprecation warning. + + message (unicode): The message to display. + filter (unicode): Filter value. + """ + stack = inspect.stack()[-1] + with warnings.catch_warnings(): + warnings.simplefilter(filter, DeprecationWarning) + warnings.warn_explicit(message, DeprecationWarning, stack[1], stack[2]) + + def print_table(data, title=None): """Print data in table format.