Update app.py
Browse files
app.py
CHANGED
|
@@ -12,9 +12,8 @@ sentiment_model = "MatteoFasulo/mdeberta-v3-base-subjectivity-sentiment-multilin
|
|
| 12 |
|
| 13 |
# Define some examples for the Gradio interface (cached to run on-the-fly)
|
| 14 |
examples = [
|
| 15 |
-
['
|
| 16 |
-
[
|
| 17 |
-
['Example3'],
|
| 18 |
]
|
| 19 |
|
| 20 |
# Custom model class for combining sentiment analysis with subjectivity detection
|
|
@@ -133,17 +132,14 @@ def analyze(text):
|
|
| 133 |
return table_data
|
| 134 |
|
| 135 |
# Update the Gradio interface
|
| 136 |
-
with gr.Blocks(theme=gr.themes.
|
| 137 |
-
|
| 138 |
-
#header { text-align: center; font-size: 2rem; font-weight: bold; margin-bottom: 10px; }
|
| 139 |
-
""") as demo:
|
| 140 |
-
gr.Markdown("<div id='header'>π Advanced Subjectivity & Sentiment Dashboard π</div>")
|
| 141 |
with gr.Row():
|
| 142 |
txt = gr.Textbox(label="Enter text to analyze", placeholder="Paste news sentence here...", lines=2)
|
| 143 |
btn = gr.Button("Analyze π", variant="primary")
|
| 144 |
with gr.Tabs():
|
| 145 |
with gr.TabItem("Raw Scores π"):
|
| 146 |
-
table = gr.Dataframe(headers=["Metric", "Value"], datatype=["str","str"], interactive=False
|
| 147 |
with gr.TabItem("About βΉοΈ"):
|
| 148 |
gr.Markdown("This dashboard uses two DeBERTa-based models (with and without sentiment integration) to detect subjectivity, alongside sentiment scores from an XLM-RoBERTa model.")
|
| 149 |
with gr.Row():
|
|
@@ -154,10 +150,9 @@ with gr.Blocks(theme=gr.themes.Soft(), css="""
|
|
| 154 |
outputs=[table],
|
| 155 |
fn=analyze,
|
| 156 |
label="Examples",
|
| 157 |
-
elem_id="example_list",
|
| 158 |
cache_examples=True,
|
| 159 |
)
|
| 160 |
# Link inputs to outputs
|
| 161 |
btn.click(fn=analyze, inputs=txt, outputs=[table])
|
| 162 |
|
| 163 |
-
demo.queue().launch(
|
|
|
|
| 12 |
|
| 13 |
# Define some examples for the Gradio interface (cached to run on-the-fly)
|
| 14 |
examples = [
|
| 15 |
+
["But then Trump came to power and sidelined the defense hawks, ushering in a dramatic shift in Republican sentiment toward America's allies and adversaries."],
|
| 16 |
+
["Boxing Day ambush & flagship attack Putin has long tried to downplay the true losses his army has faced in the Black Sea."],
|
|
|
|
| 17 |
]
|
| 18 |
|
| 19 |
# Custom model class for combining sentiment analysis with subjectivity detection
|
|
|
|
| 132 |
return table_data
|
| 133 |
|
| 134 |
# Update the Gradio interface
|
| 135 |
+
with gr.Blocks(theme=gr.themes.Base()) as demo:
|
| 136 |
+
gr.Markdown("π Advanced Subjectivity & Sentiment Dashboard π")
|
|
|
|
|
|
|
|
|
|
| 137 |
with gr.Row():
|
| 138 |
txt = gr.Textbox(label="Enter text to analyze", placeholder="Paste news sentence here...", lines=2)
|
| 139 |
btn = gr.Button("Analyze π", variant="primary")
|
| 140 |
with gr.Tabs():
|
| 141 |
with gr.TabItem("Raw Scores π"):
|
| 142 |
+
table = gr.Dataframe(headers=["Metric", "Value"], datatype=["str","str"], interactive=False)
|
| 143 |
with gr.TabItem("About βΉοΈ"):
|
| 144 |
gr.Markdown("This dashboard uses two DeBERTa-based models (with and without sentiment integration) to detect subjectivity, alongside sentiment scores from an XLM-RoBERTa model.")
|
| 145 |
with gr.Row():
|
|
|
|
| 150 |
outputs=[table],
|
| 151 |
fn=analyze,
|
| 152 |
label="Examples",
|
|
|
|
| 153 |
cache_examples=True,
|
| 154 |
)
|
| 155 |
# Link inputs to outputs
|
| 156 |
btn.click(fn=analyze, inputs=txt, outputs=[table])
|
| 157 |
|
| 158 |
+
demo.queue().launch()
|