rachman commited on
Commit
6711c73
·
verified ·
1 Parent(s): 46e8a7c

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +7 -5
src/streamlit_app.py CHANGED
@@ -9,11 +9,13 @@ from tensorflow.keras.preprocessing.sequence import pad_sequences
9
  from tensorflow.keras.models import load_model
10
  import nltk
11
 
12
- nltk.data.path.append('src')
 
 
13
 
14
- # Download the stopwords resource
15
- nltk.download('stopwords', download_dir='src')
16
- nltk.download('punkt', download_dir='src')
17
 
18
  # Load the trained model
19
  model = load_model('src/model.keras')
@@ -49,7 +51,7 @@ def text_preprocessing(text):
49
  tokens = word_tokenize(text)
50
 
51
  # Stopwords removal
52
- # tokens = [word for word in tokens if word not in stpwds_id]
53
 
54
  # Combining Tokens
55
  text = ' '.join(tokens)
 
9
  from tensorflow.keras.models import load_model
10
  import nltk
11
 
12
+ # Use /tmp for NLTK data (writable in Hugging Face Spaces)
13
+ nltk_data_dir = "/tmp/nltk_data"
14
+ nltk.data.path.append(nltk_data_dir)
15
 
16
+ # Download the stopwords and punkt resources
17
+ nltk.download('stopwords', download_dir=nltk_data_dir)
18
+ nltk.download('punkt', download_dir=nltk_data_dir)
19
 
20
  # Load the trained model
21
  model = load_model('src/model.keras')
 
51
  tokens = word_tokenize(text)
52
 
53
  # Stopwords removal
54
+ tokens = [word for word in tokens if word not in stpwds_id]
55
 
56
  # Combining Tokens
57
  text = ' '.join(tokens)