Mpavan45 commited on
Commit
d4c35a0
·
verified ·
1 Parent(s): 16212fc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -14
app.py CHANGED
@@ -183,20 +183,10 @@ st.markdown(
183
 
184
  st.markdown("<div class='prompt-box'>Paste the article content below to analyze its category with PressGuard🛡️</div>", unsafe_allow_html=True)
185
 
186
- # Ensure NLTK resources are downloaded in the correct directory
187
- nltk_data_path = '/root/nltk_data' # Use the correct path in Hugging Face Spaces
188
- if not os.path.exists(nltk_data_path):
189
- os.makedirs(nltk_data_path)
190
-
191
- # Download NLTK resources only if not already present
192
- for resource in ['punkt_tab', 'stopwords', 'wordnet']:
193
- try:
194
- nltk.data.find(f'tokenizers/{resource}' if resource == 'punkt_tab' else f'corpora/{resource}')
195
- except LookupError:
196
- nltk.download(resource, download_dir=nltk_data_path)
197
-
198
- # Set NLTK data path
199
- nltk.data.path.append(nltk_data_path)
200
 
201
  # Initialize stopwords and lemmatizer
202
  stop_words = set(stopwords.words('english')).union({"pm"})
 
183
 
184
  st.markdown("<div class='prompt-box'>Paste the article content below to analyze its category with PressGuard🛡️</div>", unsafe_allow_html=True)
185
 
186
+ # Download necessary resources
187
+ nltk.download('punkt_tab')
188
+ nltk.download('stopwords')
189
+ nltk.download('wordnet')
 
 
 
 
 
 
 
 
 
 
190
 
191
  # Initialize stopwords and lemmatizer
192
  stop_words = set(stopwords.words('english')).union({"pm"})