JainilP30 commited on
Commit
5dd6de5
·
verified ·
1 Parent(s): 4b21a8e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
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
- nltk.download('punkt')
13
- nltk.download('stopwords')
14
- nltk.download('wordnet')
 
 
 
 
 
 
 
 
 
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: