From 02d4be31e8471c63cdb111d8525602a0d3ff5ff4 Mon Sep 17 00:00:00 2001 From: Shivsharan Malage <104545490+Shivmalge@users.noreply.github.com> Date: Sat, 28 Dec 2024 17:01:47 +0530 Subject: [PATCH] app.py --- app.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 897bb81..8d327c7 100644 --- a/app.py +++ b/app.py @@ -4,10 +4,17 @@ import nltk from nltk.corpus import stopwords from nltk.stem.porter import PorterStemmer +import os + +# Force NLTK to download resources +nltk_data_dir = os.path.join(os.getcwd(), 'nltk_data') +if not os.path.exists(nltk_data_dir): + os.mkdir(nltk_data_dir) +nltk.data.path.append(nltk_data_dir) # Download required NLTK resources -nltk.download('punkt') -nltk.download('stopwords') +nltk.download('punkt', download_dir=nltk_data_dir) +nltk.download('stopwords', download_dir=nltk_data_dir) ps = PorterStemmer()