-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
85 lines (75 loc) · 2.15 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# importing libraries
from ctypes import alignment
from urllib import response
import pandas as pd
import streamlit as st
import altair as alt
from PIL import Image
import pandas as pd
import numpy as np
import re
import string
from nltk.stem import WordNetLemmatizer
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.preprocessing import LabelEncoder
from nltk.tokenize import RegexpTokenizer
from nltk import PorterStemmer, WordNetLemmatizer
from helper import *
import pickle
image = Image.open('images/cyber.jpg')
st.image(image, use_column_width= True)
st.write('''
# Cyber-bulling Tweet Recognition App
This app predicts the nature of the tweet into 6 different categories.
* Age
* Ethnicity
* Gender
* Religion
* Other Cyberbullying
* Not Cyberbullying
***
''')
# Text Box
st.header('Enter Tweet')
tweet_input = st.text_area("Tweet Input", height= 150)
print(tweet_input)
st.write('''
***
''')
# st.header("Prediction")
final_output=""
if tweet_input:
prediction = custom_input_prediction(tweet_input)
if prediction == "Age":
final_output = "Age Cyberbullying"
elif prediction == "Ethnicity":
final_output = "Ethnicity Cyberbullying"
elif prediction == "Gender":
final_output = "Gender Cyberbullying"
elif prediction == "Not Cyberbullying":
final_output = "No Cyberbullying"
elif prediction == "Other Cyberbullying":
final_output = "Other Cyberbullying"
elif prediction == "Religion":
final_output = "Religion Cyberbullying"
else:
pass
# print output on webpage
st.header("Tweet Classification")
if final_output:
final_output
else:
st.write('''
***No Tweet Text Entered!***
''')
st.write('''
***
''')
# About section
expand_bar = st.expander("About")
expand_bar.markdown('''
* **Source Code:** [https://github.com/mohd-raza/Cyber-Bully-Classification-App](https://github.com/mohd-raza/Cyber-Bully-Classification-App)
* **Dataset:** [https://www.kaggle.com/datasets/andrewmvd/cyberbullying-classification](https://www.kaggle.com/datasets/andrewmvd/cyberbullying-classification)
''')