AyoubChLin commited on
Commit
d250fdf
·
verified ·
1 Parent(s): f4ecc64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -16,6 +16,15 @@ except LookupError:
16
  # Additional imports
17
  from nltk.corpus import stopwords
18
 
 
 
 
 
 
 
 
 
 
19
  # Load the LSTM model
20
  model_path = "./my_model.h5" # Set your model path here
21
 
@@ -27,7 +36,7 @@ def load_lstm_model(model_path):
27
  def clean_text(text):
28
  # Remove stopwords
29
  stop_words = set(stopwords.words('english'))
30
- words = nltk.word_tokenize(text)
31
  filtered_words = [word for word in words if word not in stop_words]
32
 
33
  # Remove Twitter usernames
 
16
  # Additional imports
17
  from nltk.corpus import stopwords
18
 
19
+ # Download NLTK punkt tokenizer if not already downloaded
20
+ try:
21
+ nltk.data.find('tokenizers/punkt/PY3/english.pickle')
22
+ except LookupError:
23
+ nltk.download('punkt')
24
+
25
+ # Additional imports
26
+ from nltk.tokenize import word_tokenize
27
+
28
  # Load the LSTM model
29
  model_path = "./my_model.h5" # Set your model path here
30
 
 
36
  def clean_text(text):
37
  # Remove stopwords
38
  stop_words = set(stopwords.words('english'))
39
+ words = word_tokenize(text)
40
  filtered_words = [word for word in words if word not in stop_words]
41
 
42
  # Remove Twitter usernames