ebhon commited on
Commit
d51ea80
·
verified ·
1 Parent(s): 27366d7

Update app.py

Browse files

still punkt issue

Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -14,17 +14,21 @@ from nltk.tokenize import word_tokenize, sent_tokenize
14
  from sklearn.feature_extraction.text import CountVectorizer
15
 
16
  nltk_data_path = '/home/user/nltk_data'
 
17
  if not os.path.exists(nltk_data_path):
18
  os.makedirs(nltk_data_path)
 
 
 
19
  nltk.download('punkt', download_dir=nltk_data_path)
 
20
  nltk.download('stopwords', download_dir=nltk_data_path)
21
- else:
22
- if not os.path.exists(os.path.join(nltk_data_path, "tokenizers/punkt")):
23
- nltk.download('punkt', download_dir=nltk_data_path)
24
- if not os.path.exists(os.path.join(nltk_data_path, "corpora/stopwords")):
25
- nltk.download('stopwords', download_dir=nltk_data_path)
26
 
27
- nltk.data.path.append(nltk_data_path)
 
 
 
 
28
 
29
  model = load_model('model_improved.keras')
30
  vectorizer = joblib.load('vectorizer.joblib')
@@ -34,7 +38,6 @@ with open('product_mapping.json', 'r') as file1:
34
  reverse_mapping = {v: k for k, v in product_mapping.items()}
35
 
36
  lemmatizer = WordNetLemmatizer()
37
- stop_words = set(stopwords.words('english'))
38
 
39
  def clean_text(text):
40
  if text is None:
 
14
  from sklearn.feature_extraction.text import CountVectorizer
15
 
16
  nltk_data_path = '/home/user/nltk_data'
17
+
18
  if not os.path.exists(nltk_data_path):
19
  os.makedirs(nltk_data_path)
20
+
21
+ nltk.data.path.append(nltk_data_path)
22
+ if not os.path.exists(os.path.join(nltk_data_path, "tokenizers/punkt")):
23
  nltk.download('punkt', download_dir=nltk_data_path)
24
+ if not os.path.exists(os.path.join(nltk_data_path, "corpora/stopwords")):
25
  nltk.download('stopwords', download_dir=nltk_data_path)
 
 
 
 
 
26
 
27
+ from nltk.corpus import stopwords
28
+ from nltk.tokenize import sent_tokenize
29
+
30
+ stop_words = set(stopwords.words('english'))
31
+
32
 
33
  model = load_model('model_improved.keras')
34
  vectorizer = joblib.load('vectorizer.joblib')
 
38
  reverse_mapping = {v: k for k, v in product_mapping.items()}
39
 
40
  lemmatizer = WordNetLemmatizer()
 
41
 
42
  def clean_text(text):
43
  if text is None: