emirkaanozdemr commited on
Commit
54f2de6
1 Parent(s): e734efd

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +22 -15
  2. model.h5 +2 -2
  3. requirements.txt +5 -3
app.py CHANGED
@@ -1,20 +1,27 @@
1
  import streamlit as st
2
- import numpy as np
3
  from sklearn.feature_extraction.text import CountVectorizer
 
 
4
  from tensorflow.keras.models import load_model
 
 
5
 
6
  model=load_model("model.h5")
7
- def transform(password):
8
- character=[]
9
- for i in password:
10
- character.append(i)
11
- return character
12
- vect=CountVectorizer(tokenizer=transform)
13
- input=st.text_input("Your Password",type="password")
14
- if input is not None:
15
- data=vect.fit_transform([input]).toarray()
16
- if st.button("Predict"):
17
- prediction=model.predict(data)
18
- class_names=["Weak","Medium","Strong"]
19
- prediction=class_names(np.argmax(prediction))
20
- st.write(prediction)
 
 
 
 
 
1
  import streamlit as st
 
2
  from sklearn.feature_extraction.text import CountVectorizer
3
+ from textblob import TextBlob
4
+ from nltk.stem import PorterStemmer
5
  from tensorflow.keras.models import load_model
6
+ import numpy as np
7
+ import nltk
8
 
9
  model=load_model("model.h5")
10
+ pr=PorterStemmer()
11
+ def lemmafn(text):
12
+ words=TextBlob(text).words
13
+ return [pr.stem(word) for word in words]
14
+ vect=CountVectorizer(ngram_range=(1,4),max_features=100000,analyzer=lemmafn)
15
+ st.title("Predicting Emotion of Text")
16
+ text=st.text_area("Your text")
17
+ if text is not None:
18
+ text=text.lower()
19
+ text=text.replace("[^\w\s]","")
20
+ text=text.replace("\n","")
21
+ text=text.replace("\d+","")
22
+ text=vect.fit_transform([text])
23
+ if st.button("Predict"):
24
+ prediction=model.predict(text)
25
+ class_names=["Joy","Love","Anger","Sadness","Fear","Surprise"]
26
+ emotion=class_names[np.argmax(prediction)]
27
+ st.write(emotion)
model.h5 CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:653e6066760ee1ddee2036a034a06c8d876b35b132a52eb6810a3b2e9e3f84da
3
- size 463360
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:732d0fa8473925ef2a813886b6570cc0e9fc8b0d03fa1319573150c09a86a83a
3
+ size 17102424
requirements.txt CHANGED
@@ -1,4 +1,6 @@
1
- scikit-learn
2
- numpy
3
  streamlit
4
- tensorflow
 
 
 
 
 
 
 
1
  streamlit
2
+ scikit-learn
3
+ textblob
4
+ tensorflow
5
+ nltk
6
+ numpy