-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
58 lines (34 loc) · 1.02 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import streamlit as st
import pickle
import nltk
import string
from nltk.corpus import stopwords
from nltk.stem.porter import PorterStemmer
ps = PorterStemmer( )
def data_clening(text):
text = text.lower()
text = nltk.word_tokenize(text)
y = []
for i in text:
if i.isalnum():
y.append(i)
x = []
for i in y:
if i not in stopwords.words('english') and i not in string.punctuation:
x.append(i)
z = []
for i in x:
z.append( ps.stem(i))
return ' '.join(z)
tfid = pickle.load(open('vectoriz.pkl', 'rb'))
model = pickle.load(open('nodel.pkl', 'rb'))
st.title('SMS Spam Detection')
input_sms = st.text_area('Enter SMS')
if st.button('Predict'):
data_cl = data_clening(input_sms)
vac = tfid.transform([data_cl])
result = model.predict(vac)[0]
if result == 1:
st.header('Spam')
else:
st.header('Not Spam')