Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,9 +9,18 @@ from nltk.corpus import stopwords
|
|
9 |
from nltk.stem import WordNetLemmatizer
|
10 |
from nltk.tokenize import word_tokenize
|
11 |
import nltk
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# ============ Load Models and Tokenizers ============
|
17 |
with open("logreg_model.pkl", "rb") as f:
|
|
|
9 |
from nltk.stem import WordNetLemmatizer
|
10 |
from nltk.tokenize import word_tokenize
|
11 |
import nltk
|
12 |
+
import os
|
13 |
+
import zipfile
|
14 |
+
|
15 |
+
# Unzip local nltk_data.zip if not already unzipped
|
16 |
+
nltk_data_path = os.path.join(os.path.dirname(__file__), 'nltk_data')
|
17 |
+
if not os.path.exists(nltk_data_path):
|
18 |
+
with zipfile.ZipFile('nltk_data.zip', 'r') as zip_ref:
|
19 |
+
zip_ref.extractall(nltk_data_path)
|
20 |
+
|
21 |
+
# Tell NLTK to use the local data path
|
22 |
+
nltk.data.path.append(nltk_data_path)
|
23 |
+
|
24 |
|
25 |
# ============ Load Models and Tokenizers ============
|
26 |
with open("logreg_model.pkl", "rb") as f:
|