miso-belica / sumy

Module for automatic summarization of text documents and HTML pages.
https://miso-belica.github.io/sumy/
Apache License 2.0
3.51k stars 529 forks source link

Ability to access UserWarnings #177

Closed mrx23dot closed 2 years ago

mrx23dot commented 2 years ago

After sentence is summarised I would like to access any warnings e.g:

C:\py38_64\lib\site-packages\sumy\summarizers\lsa.py:76: UserWarning: Number of words (14) is lower than number of sentences (15). LSA algorithm may not work properly.

so I would just keep the original sentence segment instead.

miso-belica commented 2 years ago

https://docs.python.org/3/library/warnings.html#warnings.catch_warnings

mrx23dot commented 2 years ago

This one did it https://stackoverflow.com/questions/5644836/in-python-how-does-one-catch-warnings-as-if-they-were-exceptions thanks