Search code examples
pythonnlpjupyter-notebookspacytextacy

Textacy with Jupyter Notebook: How to suppress multiple error warnings?


I am using Textacy (on top of Spacy) to process many snippets of text.

Specifically I use Textacy´s Readability scores. Since I have a lot of short texts I get a warning that I need to suppress because it otherwise will crash my notebook.

My code:

def readability(x):
    d = nlp(x);
    t = textacy.TextStats(d);
    return t.readability_stats;

df["readability"] = df.message.apply(readability)

I get this warning for every entry of my dataframe (which is to be expected):

2017-09-23 19:44:23,283 : WARNING : SMOG score may be unreliable for n_sents < 30

How can I suppress that? I couldn´t find any hint in the docs nor on the web.

Thanks in advance for any hint in the right direction.


Solution

  • Add the following two lines at the top of your notebook and execute them

     import warnings
     warnings.filterwarnings('ignore')