Spaces:
Sleeping
Sleeping
Abhinav Jangra
commited on
Commit
·
136d7b4
1
Parent(s):
4b5b3ac
Delete app.py
Browse files
app.py
DELETED
@@ -1,77 +0,0 @@
|
|
1 |
-
import streamlit as st
|
2 |
-
import pickle
|
3 |
-
import string
|
4 |
-
from nltk.corpus import stopwords
|
5 |
-
import nltk
|
6 |
-
nltk.download('punkt')
|
7 |
-
nltk.download('stopwords')
|
8 |
-
|
9 |
-
|
10 |
-
from nltk.stem.porter import PorterStemmer
|
11 |
-
|
12 |
-
ps=PorterStemmer()
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
def transform_text(text):
|
18 |
-
text=text.lower()
|
19 |
-
text=nltk.word_tokenize(text)
|
20 |
-
|
21 |
-
y=[]
|
22 |
-
for i in text:
|
23 |
-
if i.isalnum():
|
24 |
-
y.append(i)
|
25 |
-
|
26 |
-
text=y[:]
|
27 |
-
y.clear()
|
28 |
-
|
29 |
-
for i in text:
|
30 |
-
if i not in stopwords.words('english') and i not in string.punctuation:
|
31 |
-
y.append(i)
|
32 |
-
|
33 |
-
text=y[:]
|
34 |
-
y.clear()
|
35 |
-
|
36 |
-
for i in text:
|
37 |
-
y.append(ps.stem(i))
|
38 |
-
|
39 |
-
|
40 |
-
return " ".join(y)
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
tfidf=pickle.load(open('vectorizer.pkl','rb'))
|
45 |
-
model=pickle.load(open('model.pkl','rb'))
|
46 |
-
|
47 |
-
st.title("EMAIL/SMS SPAM CLASSIFIER")
|
48 |
-
|
49 |
-
#follow documentation for syntax and fn
|
50 |
-
|
51 |
-
input_sms=st.text_input("Enter the message :)")
|
52 |
-
|
53 |
-
if st.button('predict'):
|
54 |
-
|
55 |
-
#1.preprocess
|
56 |
-
transformed_sms=transform_text(input_sms)
|
57 |
-
#2.vectorize
|
58 |
-
vector_input=tfidf.transform([transformed_sms])
|
59 |
-
#3.predict
|
60 |
-
result=model.predict(vector_input)[0]
|
61 |
-
#4.display
|
62 |
-
|
63 |
-
if result==1:
|
64 |
-
st.header("make some friends loner")
|
65 |
-
|
66 |
-
else:
|
67 |
-
st.header("not spam uwu")
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|