Spaces:
Sleeping
Sleeping
File size: 3,636 Bytes
3c77d98 cb58c8d 3c77d98 cb58c8d 3c77d98 481f13d 3c77d98 4165ebd cb58c8d 481f13d cb58c8d 481f13d 3c77d98 5e13818 b523842 a0519f7 5e13818 d2324b7 3c77d98 cb58c8d 3c77d98 7ba3a06 481f13d 3c77d98 d2324b7 481f13d |
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 |
import data_prep
import model_predict
import gradio as gr
# model_dict = {
# "BERT-Base": "research-dump/bert-base-uncased_deletion_multiclass_complete_Final",
# "BERT-Large": "research-dump/bert-large-uncased_deletion_multiclass_complete_final",
# "RoBERTa-Base": "research-dump/roberta-base_deletion_multiclass_complete_final",
# "RoBERTa-Large": "research-dump/roberta-large_deletion_multiclass_complete_final"
# }
model_dict = {
"Outcome Prediction": "outcome",
"Stance Detection": "stance",
"Policy Prediction": "policy",
"Sentiment Analysis": "sentiment",
"Offensive Language Detection": "offensive"
}
def process_url(url, model_name):
model_name = model_dict[model_name]
processed_text = data_prep.process_data(url)
final_scores = model_predict.predict_text(processed_text, model_name)
if model_name == 'outcome':
highest_prob_item = max(final_scores, key=lambda x: x['score'])
highest_prob_label = highest_prob_item['outcome']
highest_prob = highest_prob_item['score']
progress_bars = {item['outcome']: item['score'] for item in final_scores}
return processed_text, highest_prob_label, highest_prob, progress_bars
else:
return processed_text, "", "", final_scores
title = 'Wide-Analysis: A Wikipedia Deletion Discussion Analysis Suite'
desc = """ Wide-Analysis is a suite of tools for analyzing Wikipedia deletion discussions. It is designed to help researchers and practitioners to understand the dynamics of deletion discussions, and to develop tools for supporting the decision-making process in Wikipedia. The suite includes a set of tools for collecting, processing, and analyzing deletion discussions. The package contains the following functionalities
- Outcome Prediction: Predicting the outcome of a deletion discussion, the outcome can be the decision made with the discussion (e.g., keep, delete, merge, etc.) (determined from the complete discussion)
- Stance Detection: Identifying the stance of the participants in the discussion, in relation to the deletion decision.(determined from each individual comment in discussion)
- Policy Prediction: Predicting the policy that is most relevant to the comments of the participants in the discussion.(determined from each individual comment in discussion)
- Sentiment Prediction: Predicting the sentiment of the participants in the discussion, in relation to the deletion decision.(determined from each individual comment in discussion)
- Offensive Language Detection: Detecting offensive language in the comments of the participants in the discussion.(determined from each individual comment in discussion)
The input to the classifier is a URL of a Wikipedia deletion discussion page with the task listed in the drop-down box, and the output is the predicted label of the discussion, along with the probability of the predicted label, and the probabilities of all the labels.
"""
url_input = gr.Textbox(label="URL")
model_name_input = gr.Dropdown(label="Choose the Task", choices=list(model_dict.keys()), value=list(model_dict.keys())[0])
outputs = [
gr.Textbox(label="Processed Text"),
gr.Textbox(label="Label with Highest Probability"), # This will only be used for the outcome task
gr.Textbox(label="Probability"), # This will only be used for the outcome task
gr.JSON(label="All Labels and Probabilities") # This will be used for all tasks
]
demo = gr.Interface(fn=process_url, inputs=[url_input, model_name_input], outputs=outputs, title=title, description=desc)
demo.launch() # share=True
|