Spaces:
Sleeping
Sleeping
Kingston Yip
commited on
Commit
·
2427ad9
1
Parent(s):
39a4d7e
Revert "changes"
Browse filesThis reverts commit 39a4d7e22634cd38c0f8a717fbfefa831ad24724.
- app.py +8 -12
- saved_tweets.txt +0 -0
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import pandas as pd
|
|
| 5 |
import comments
|
| 6 |
from random import randint
|
| 7 |
|
|
|
|
| 8 |
def predict_cyberbullying_probability(sentence, tokenizer, model):
|
| 9 |
# Preprocess the input sentence
|
| 10 |
inputs = tokenizer(sentence, padding='max_length', return_token_type_ids=False, return_attention_mask=True, truncation=True, max_length=512, return_tensors='pt')
|
|
@@ -78,21 +79,16 @@ with st.form("my_form"):
|
|
| 78 |
default = "I'm nice at ping pong"
|
| 79 |
tweet = st.text_area(label="Enter Text:",value=default)
|
| 80 |
submitted = st.form_submit_button("Analyze textbox")
|
| 81 |
-
random = st.form_submit_button("
|
| 82 |
|
| 83 |
if random:
|
| 84 |
tweet = comments.comments[randint(0, 354)]
|
| 85 |
st.write(tweet)
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
f.write("\n")
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
df = perform_cyberbullying_analysis(tweet)
|
| 96 |
-
st.table(df)
|
| 97 |
else:
|
| 98 |
perform_default_analysis(model_name)
|
|
|
|
| 5 |
import comments
|
| 6 |
from random import randint
|
| 7 |
|
| 8 |
+
|
| 9 |
def predict_cyberbullying_probability(sentence, tokenizer, model):
|
| 10 |
# Preprocess the input sentence
|
| 11 |
inputs = tokenizer(sentence, padding='max_length', return_token_type_ids=False, return_attention_mask=True, truncation=True, max_length=512, return_tensors='pt')
|
|
|
|
| 79 |
default = "I'm nice at ping pong"
|
| 80 |
tweet = st.text_area(label="Enter Text:",value=default)
|
| 81 |
submitted = st.form_submit_button("Analyze textbox")
|
| 82 |
+
random = st.form_submit_button("Analyze a random 😈😈😈 tweet")
|
| 83 |
|
| 84 |
if random:
|
| 85 |
tweet = comments.comments[randint(0, 354)]
|
| 86 |
st.write(tweet)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
df = perform_cyberbullying_analysis(tweet)
|
| 90 |
+
|
| 91 |
+
# Display the cached table
|
| 92 |
+
st.table(df)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
else:
|
| 94 |
perform_default_analysis(model_name)
|
saved_tweets.txt
DELETED
|
File without changes
|