Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,8 +12,18 @@ from nltk.stem import WordNetLemmatizer
|
|
| 12 |
from nltk.tokenize import word_tokenize, sent_tokenize
|
| 13 |
from sklearn.feature_extraction.text import CountVectorizer
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
model = load_model('model_improved.keras')
|
| 19 |
vectorizer = joblib.load('vectorizer.joblib')
|
|
@@ -52,9 +62,9 @@ def make_prediction(input_text):
|
|
| 52 |
return predicted_label
|
| 53 |
|
| 54 |
st.title("Text Classification with NLP")
|
| 55 |
-
st.write("
|
| 56 |
|
| 57 |
-
user_input = st.text_area("
|
| 58 |
if st.button("Classify"):
|
| 59 |
if user_input:
|
| 60 |
result = make_prediction(user_input)
|
|
|
|
| 12 |
from nltk.tokenize import word_tokenize, sent_tokenize
|
| 13 |
from sklearn.feature_extraction.text import CountVectorizer
|
| 14 |
|
| 15 |
+
nltk_data_path = '/home/user/nltk_data'
|
| 16 |
+
if not os.path.exists(nltk_data_path):
|
| 17 |
+
os.makedirs(nltk_data_path)
|
| 18 |
+
nltk.download('punkt', download_dir=nltk_data_path)
|
| 19 |
+
nltk.download('stopwords', download_dir=nltk_data_path)
|
| 20 |
+
else:
|
| 21 |
+
if not os.path.exists(os.path.join(nltk_data_path, "tokenizers/punkt")):
|
| 22 |
+
nltk.download('punkt', download_dir=nltk_data_path)
|
| 23 |
+
if not os.path.exists(os.path.join(nltk_data_path, "corpora/stopwords")):
|
| 24 |
+
nltk.download('stopwords', download_dir=nltk_data_path)
|
| 25 |
+
|
| 26 |
+
nltk.data.path.append(nltk_data_path)
|
| 27 |
|
| 28 |
model = load_model('model_improved.keras')
|
| 29 |
vectorizer = joblib.load('vectorizer.joblib')
|
|
|
|
| 62 |
return predicted_label
|
| 63 |
|
| 64 |
st.title("Text Classification with NLP")
|
| 65 |
+
st.write("Please type the customer's complaint into this text area")
|
| 66 |
|
| 67 |
+
user_input = st.text_area("Write here!", "")
|
| 68 |
if st.button("Classify"):
|
| 69 |
if user_input:
|
| 70 |
result = make_prediction(user_input)
|