Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,6 +9,7 @@ import textstat
|
|
| 9 |
import trafilatura
|
| 10 |
import requests
|
| 11 |
from bs4 import BeautifulSoup
|
|
|
|
| 12 |
|
| 13 |
# constants
|
| 14 |
MAX_TEXT_LENGTH = 1500
|
|
@@ -24,6 +25,12 @@ def _load_nlp_models() -> typing.Dict[str, typing.Any]:
|
|
| 24 |
"""
|
| 25 |
Loads NLP models into memory and caches them.
|
| 26 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
sentiment_analyzer = pipeline(
|
| 28 |
"text-classification",
|
| 29 |
model="ProsusAI/finbert",
|
|
|
|
| 9 |
import trafilatura
|
| 10 |
import requests
|
| 11 |
from bs4 import BeautifulSoup
|
| 12 |
+
import nltk
|
| 13 |
|
| 14 |
# constants
|
| 15 |
MAX_TEXT_LENGTH = 1500
|
|
|
|
| 25 |
"""
|
| 26 |
Loads NLP models into memory and caches them.
|
| 27 |
"""
|
| 28 |
+
try:
|
| 29 |
+
nltk.data.find('tokenizers/punkt')
|
| 30 |
+
except LookupError:
|
| 31 |
+
nltk.download('punkt')
|
| 32 |
+
nltk.download('punkt_tab')
|
| 33 |
+
|
| 34 |
sentiment_analyzer = pipeline(
|
| 35 |
"text-classification",
|
| 36 |
model="ProsusAI/finbert",
|