Spaces:
Sleeping
Sleeping
Commit
·
d7f8b52
1
Parent(s):
ebd52bf
test 3 without model
Browse files
app.py
CHANGED
@@ -8,7 +8,6 @@ from transformers import pipeline
|
|
8 |
# Model and pipeline
|
9 |
MODEL_PATH = 'danielcd99/multilanguage-toxicity-classifier'
|
10 |
|
11 |
-
"""
|
12 |
def load_pipeline():
|
13 |
pipe=pipeline(
|
14 |
"text-classification",
|
@@ -17,7 +16,7 @@ def load_pipeline():
|
|
17 |
return pipe
|
18 |
|
19 |
pipe = load_pipeline()
|
20 |
-
|
21 |
|
22 |
# Title and subtitle
|
23 |
st.title("Toxicity Detection")
|
@@ -25,3 +24,24 @@ st.subheader("This is an app for detecting toxicity in tweets written in portugu
|
|
25 |
"Write the name of the user (without @) and select the number of tweets you want to check.")
|
26 |
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
# Model and pipeline
|
9 |
MODEL_PATH = 'danielcd99/multilanguage-toxicity-classifier'
|
10 |
|
|
|
11 |
def load_pipeline():
|
12 |
pipe=pipeline(
|
13 |
"text-classification",
|
|
|
16 |
return pipe
|
17 |
|
18 |
pipe = load_pipeline()
|
19 |
+
|
20 |
|
21 |
# Title and subtitle
|
22 |
st.title("Toxicity Detection")
|
|
|
24 |
"Write the name of the user (without @) and select the number of tweets you want to check.")
|
25 |
|
26 |
|
27 |
+
# User information
|
28 |
+
with st.form(key='forms'):
|
29 |
+
st.markdown(
|
30 |
+
"""#### Tweets are classified in:
|
31 |
+
- 0: Harmless
|
32 |
+
- 1: Toxic
|
33 |
+
""")
|
34 |
+
username = st.text_input(label='Username:')
|
35 |
+
number_of_tweets = st.selectbox(
|
36 |
+
'How many tweets do you want to check?',
|
37 |
+
(5, 10, 20, 30))
|
38 |
+
submit_button = st.form_submit_button(label='Analyze')
|
39 |
+
|
40 |
+
if submit_button:
|
41 |
+
"""
|
42 |
+
scraper = TwitterUserScraper(username)
|
43 |
+
tweets = get_tweets(scraper, number_of_tweets)
|
44 |
+
predictions = get_predictions(tweets, pipe)
|
45 |
+
|
46 |
+
st.table(pd.DataFrame({'tweet': tweets, 'toxic':predictions}))
|
47 |
+
"""
|