Archisman Karmakar
commited on
Commit
·
270fc78
1
Parent(s):
2e89a9b
2025.03.24.post1
Browse files
dashboard.py
CHANGED
@@ -46,7 +46,7 @@ def free_memory():
|
|
46 |
|
47 |
def create_sample_example1():
|
48 |
st.write("""
|
49 |
-
|
50 |
""")
|
51 |
graph = """
|
52 |
digraph {
|
@@ -64,7 +64,7 @@ def create_sample_example1():
|
|
64 |
Disgust [label="Disgust: 0.015257259", fillcolor="#deffe1", fontcolor="black"];
|
65 |
Fear [label="Fear: 0.601871967", fillcolor="#deffe1", fontcolor="black"];
|
66 |
Joy [label="Joy: 0.00410547", fillcolor="#deffe1", fontcolor="black"];
|
67 |
-
|
68 |
Sadness [label="Sadness: 0.245294735", fillcolor="#deffe1", fontcolor="black"];
|
69 |
Surprise [label="Surprise: 0.019189769", fillcolor="#deffe1", fontcolor="black"];
|
70 |
|
@@ -74,13 +74,14 @@ def create_sample_example1():
|
|
74 |
// Establish the tree structure
|
75 |
Input -> Output;
|
76 |
Input -> Sentiment;
|
77 |
-
Sentiment ->
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
84 |
}
|
85 |
"""
|
86 |
st.graphviz_chart(graph)
|
@@ -88,7 +89,7 @@ def create_sample_example1():
|
|
88 |
|
89 |
def create_sample_example2():
|
90 |
st.write("""
|
91 |
-
|
92 |
""")
|
93 |
graph = """
|
94 |
digraph {
|
@@ -98,7 +99,7 @@ def create_sample_example2():
|
|
98 |
|
99 |
// Define nodes with custom colors
|
100 |
Input [label="Input:\nu rlly think all that talk means u tough? lol, when I step up, u ain't gon say sh*t", fillcolor="#ffe6de", fontcolor="black"];
|
101 |
-
Output [label="Output:\nyou really think all that talk makes you tough lol when i step up you are not going to say anything", fillcolor="#ffe6de", fontcolor="black"];
|
102 |
Sentiment [label="Sentiment:\nNEGATIVE", fillcolor="#ecdeff", fontcolor="black"];
|
103 |
|
104 |
// Emotion nodes with a uniform style
|
@@ -106,7 +107,7 @@ def create_sample_example2():
|
|
106 |
Disgust [label="Disgust: 0.039282672", fillcolor="#deffe1", fontcolor="black"];
|
107 |
Fear [label="Fear: 0.014349542", fillcolor="#deffe1", fontcolor="black"];
|
108 |
Joy [label="Joy: 0.048965044", fillcolor="#deffe1", fontcolor="black"];
|
109 |
-
|
110 |
Sadness [label="Sadness: 0.021111647", fillcolor="#deffe1", fontcolor="black"];
|
111 |
Surprise [label="Surprise: 0.237405464", fillcolor="#deffe1", fontcolor="black"];
|
112 |
|
@@ -116,13 +117,14 @@ def create_sample_example2():
|
|
116 |
// Establish the tree structure
|
117 |
Input -> Output;
|
118 |
Input -> Sentiment;
|
119 |
-
Sentiment ->
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
|
|
126 |
}
|
127 |
"""
|
128 |
st.graphviz_chart(graph)
|
@@ -147,19 +149,19 @@ def create_footer():
|
|
147 |
# 🚀 Contributors Section
|
148 |
with col1:
|
149 |
st.markdown("### 🚀 Contributors")
|
150 |
-
st.write("**Archisman Karmakar**")
|
151 |
st.write("[🔗 LinkedIn](https://www.linkedin.com/in/archismankarmakar/) | [🐙 GitHub](https://www.github.com/ArchismanKarmakar) | [📊 Kaggle](https://www.kaggle.com/archismancoder)")
|
152 |
|
153 |
-
st.write("**Sumon Chatterjee**")
|
154 |
st.write("[🔗 LinkedIn](https://www.linkedin.com/in/sumon-chatterjee-3b3b43227) | [🐙 GitHub](https://github.com/Sumon670) | [📊 Kaggle](https://www.kaggle.com/sumonchatterjee)")
|
155 |
|
156 |
# 🎓 Mentors Section
|
157 |
with col2:
|
158 |
st.markdown("### 🎓 Mentors")
|
159 |
-
st.write("**Prof. Anupam Mondal**")
|
160 |
st.write("[🔗 LinkedIn](https://www.linkedin.com/in/anupam-mondal-ph-d-8a7a1a39/) | [📚 Google Scholar](https://scholar.google.com/citations?user=ESRR9o4AAAAJ&hl=en) | [🌐 Website](https://sites.google.com/view/anupammondal/home)")
|
161 |
|
162 |
-
st.write("**Prof. Sainik Kumar Mahata**")
|
163 |
st.write("[��� LinkedIn](https://www.linkedin.com/in/mahatasainikk) | [📚 Google Scholar](https://scholar.google.co.in/citations?user=OcJDM50AAAAJ&hl=en) | [🌐 Website](https://sites.google.com/view/sainik-kumar-mahata/home)")
|
164 |
|
165 |
# 📌 Research Project Info Section
|
@@ -174,21 +176,25 @@ def create_footer():
|
|
174 |
def show_dashboard():
|
175 |
# free_memory()
|
176 |
st.title("Tachygraphy Micro-text Analysis & Normalization")
|
177 |
-
st.write("""
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
|
|
|
|
|
|
|
|
192 |
|
193 |
create_footer()
|
194 |
|
@@ -196,7 +202,7 @@ def show_dashboard():
|
|
196 |
|
197 |
create_sample_example1()
|
198 |
|
199 |
-
|
200 |
|
201 |
|
202 |
def __main__():
|
|
|
46 |
|
47 |
def create_sample_example1():
|
48 |
st.write("""
|
49 |
+
#### Sample Example 1
|
50 |
""")
|
51 |
graph = """
|
52 |
digraph {
|
|
|
64 |
Disgust [label="Disgust: 0.015257259", fillcolor="#deffe1", fontcolor="black"];
|
65 |
Fear [label="Fear: 0.601871967", fillcolor="#deffe1", fontcolor="black"];
|
66 |
Joy [label="Joy: 0.00410547", fillcolor="#deffe1", fontcolor="black"];
|
67 |
+
Neutral [label="Neutral: 0.0341026", fillcolor="#deffe1", fontcolor="black"];
|
68 |
Sadness [label="Sadness: 0.245294735", fillcolor="#deffe1", fontcolor="black"];
|
69 |
Surprise [label="Surprise: 0.019189769", fillcolor="#deffe1", fontcolor="black"];
|
70 |
|
|
|
74 |
// Establish the tree structure
|
75 |
Input -> Output;
|
76 |
Input -> Sentiment;
|
77 |
+
Sentiment -> Emotion
|
78 |
+
Emotion -> Anger;
|
79 |
+
Emotion -> Disgust;
|
80 |
+
Emotion -> Fear;
|
81 |
+
Emotion -> Joy;
|
82 |
+
Emotion -> Neutral;
|
83 |
+
Emotion -> Sadness;
|
84 |
+
Emotion -> Surprise;
|
85 |
}
|
86 |
"""
|
87 |
st.graphviz_chart(graph)
|
|
|
89 |
|
90 |
def create_sample_example2():
|
91 |
st.write("""
|
92 |
+
#### Sample Example 2
|
93 |
""")
|
94 |
graph = """
|
95 |
digraph {
|
|
|
99 |
|
100 |
// Define nodes with custom colors
|
101 |
Input [label="Input:\nu rlly think all that talk means u tough? lol, when I step up, u ain't gon say sh*t", fillcolor="#ffe6de", fontcolor="black"];
|
102 |
+
Output [label="Output:\nyou really think all that talk makes you tough [lol](laughed out loud) when i step up you are not going to say anything", fillcolor="#ffe6de", fontcolor="black"];
|
103 |
Sentiment [label="Sentiment:\nNEGATIVE", fillcolor="#ecdeff", fontcolor="black"];
|
104 |
|
105 |
// Emotion nodes with a uniform style
|
|
|
107 |
Disgust [label="Disgust: 0.039282672", fillcolor="#deffe1", fontcolor="black"];
|
108 |
Fear [label="Fear: 0.014349542", fillcolor="#deffe1", fontcolor="black"];
|
109 |
Joy [label="Joy: 0.048965044", fillcolor="#deffe1", fontcolor="black"];
|
110 |
+
Neutral [label="Neutral: 0.494852662", fillcolor="#deffe1", fontcolor="black"];
|
111 |
Sadness [label="Sadness: 0.021111647", fillcolor="#deffe1", fontcolor="black"];
|
112 |
Surprise [label="Surprise: 0.237405464", fillcolor="#deffe1", fontcolor="black"];
|
113 |
|
|
|
117 |
// Establish the tree structure
|
118 |
Input -> Output;
|
119 |
Input -> Sentiment;
|
120 |
+
Sentiment -> Emotion
|
121 |
+
Emotion -> Anger;
|
122 |
+
Emotion -> Disgust;
|
123 |
+
Emotion -> Fear;
|
124 |
+
Emotion -> Joy;
|
125 |
+
Emotion -> Neutral;
|
126 |
+
Emotion -> Sadness;
|
127 |
+
Emotion -> Surprise;
|
128 |
}
|
129 |
"""
|
130 |
st.graphviz_chart(graph)
|
|
|
149 |
# 🚀 Contributors Section
|
150 |
with col1:
|
151 |
st.markdown("### 🚀 Contributors")
|
152 |
+
st.write("##### **Archisman Karmakar**")
|
153 |
st.write("[🔗 LinkedIn](https://www.linkedin.com/in/archismankarmakar/) | [🐙 GitHub](https://www.github.com/ArchismanKarmakar) | [📊 Kaggle](https://www.kaggle.com/archismancoder)")
|
154 |
|
155 |
+
st.write("##### **Sumon Chatterjee**")
|
156 |
st.write("[🔗 LinkedIn](https://www.linkedin.com/in/sumon-chatterjee-3b3b43227) | [🐙 GitHub](https://github.com/Sumon670) | [📊 Kaggle](https://www.kaggle.com/sumonchatterjee)")
|
157 |
|
158 |
# 🎓 Mentors Section
|
159 |
with col2:
|
160 |
st.markdown("### 🎓 Mentors")
|
161 |
+
st.write("##### **Prof. Anupam Mondal**")
|
162 |
st.write("[🔗 LinkedIn](https://www.linkedin.com/in/anupam-mondal-ph-d-8a7a1a39/) | [📚 Google Scholar](https://scholar.google.com/citations?user=ESRR9o4AAAAJ&hl=en) | [🌐 Website](https://sites.google.com/view/anupammondal/home)")
|
163 |
|
164 |
+
st.write("##### **Prof. Sainik Kumar Mahata**")
|
165 |
st.write("[��� LinkedIn](https://www.linkedin.com/in/mahatasainikk) | [📚 Google Scholar](https://scholar.google.co.in/citations?user=OcJDM50AAAAJ&hl=en) | [🌐 Website](https://sites.google.com/view/sainik-kumar-mahata/home)")
|
166 |
|
167 |
# 📌 Research Project Info Section
|
|
|
176 |
def show_dashboard():
|
177 |
# free_memory()
|
178 |
st.title("Tachygraphy Micro-text Analysis & Normalization")
|
179 |
+
st.write(f"""Welcome to the Tachygraphy Micro-text Analysis & Normalization Project. This application is designed to analyze text data through three stages:""")
|
180 |
+
coltl1, coltl2 = st.columns(2)
|
181 |
+
with coltl1:
|
182 |
+
st.write("""
|
183 |
+
1. Sentiment Polarity Analysis
|
184 |
+
2. Emotion Mood-tag Analysis
|
185 |
+
3. Text Transformation & Normalization
|
186 |
+
4. Stacked all 3 stages with their best models
|
187 |
+
5. Data Correction & Collection
|
188 |
+
""")
|
189 |
+
with coltl2:
|
190 |
+
st.write("""
|
191 |
+
- Training Source: [GitHub @ Tachygraphy Micro-text Analysis & Normalization](https://github.com/ArchismanKarmakar/Tachygraphy-Microtext-Analysis-And-Normalization)
|
192 |
+
- Kaggle Collections: [Kaggle @ Tachygraphy Micro-text Analysis & Normalization](https://www.kaggle.com/datasets/archismancoder/dataset-tachygraphy/data?select=Tachygraphy_MicroText-AIO-V3.xlsx)
|
193 |
+
- Hugging Face Org: [Hugging Face @ Tachygraphy Micro-text Analysis & Normalization](https://huggingface.co/Tachygraphy-Microtext-Normalization-IEMK25)
|
194 |
+
- Deployment Source: [GitHub](https://github.com/ArchismanKarmakar/Tachygraphy-Microtext-Analysis-And-Normalization-Deployment-Source-HuggingFace_Streamlit_JPX14032025)
|
195 |
+
- Streamlit Deployemnt: [Streamlit](https://tachygraphy-microtext.streamlit.app/)
|
196 |
+
- Hugging Face Space Deployment: [Hugging Face Space](https://huggingface.co/spaces/Tachygraphy-Microtext-Normalization-IEMK25/Tachygraphy-Microtext-Analysis-and-Normalization-ArchismanCoder)
|
197 |
+
""")
|
198 |
|
199 |
create_footer()
|
200 |
|
|
|
202 |
|
203 |
create_sample_example1()
|
204 |
|
205 |
+
create_sample_example2()
|
206 |
|
207 |
|
208 |
def __main__():
|
data_collection_form/data_collector.py
CHANGED
@@ -250,7 +250,7 @@ def show_data_collector():
|
|
250 |
col1, col2 = st.columns(2)
|
251 |
with col1:
|
252 |
feedback = st.text_input(
|
253 |
-
"Enter the correct expanded standard formal English text:",
|
254 |
key="feedback_input"
|
255 |
)
|
256 |
with col2:
|
@@ -260,11 +260,11 @@ def show_data_collector():
|
|
260 |
)
|
261 |
|
262 |
st.warning(
|
263 |
-
"The correct slider is for the probability of
|
264 |
|
265 |
|
266 |
|
267 |
-
st.write("#### Sentiment Polarity
|
268 |
SENTIMENT_POLARITY_LABELS = ["negative", "neutral", "positive"]
|
269 |
|
270 |
model_names1 = list(MODEL_OPTIONS1.keys())
|
@@ -277,7 +277,7 @@ def show_data_collector():
|
|
277 |
sentiment_cols = st.columns(len(SENTIMENT_POLARITY_LABELS))
|
278 |
for idx, label in enumerate(SENTIMENT_POLARITY_LABELS):
|
279 |
with sentiment_cols[idx]:
|
280 |
-
st.write(f"**{label.capitalize()}**")
|
281 |
# Create two subcolumns for "Correct" and "Wrong"
|
282 |
subcol_correct, subcol_wrong = st.columns(2)
|
283 |
with subcol_correct:
|
@@ -308,7 +308,7 @@ def show_data_collector():
|
|
308 |
# ---------------------------
|
309 |
# Emotion Feedback
|
310 |
# ---------------------------
|
311 |
-
st.write("#### Emotion
|
312 |
EMOTION_MOODTAG_LABELS = [
|
313 |
"anger", "disgust", "fear", "joy", "neutral",
|
314 |
"sadness", "surprise"
|
@@ -331,7 +331,7 @@ def show_data_collector():
|
|
331 |
main_cols = st.columns(len(row_labels))
|
332 |
for idx, label in enumerate(row_labels):
|
333 |
with main_cols[idx]:
|
334 |
-
st.write(f"**{label.capitalize()}**")
|
335 |
# Create two subcolumns for correct and wrong values.
|
336 |
subcol_correct, subcol_wrong = st.columns(2)
|
337 |
with subcol_correct:
|
@@ -358,7 +358,7 @@ def show_data_collector():
|
|
358 |
|
359 |
|
360 |
# Use form_submit_button instead of st.button inside a form
|
361 |
-
submit_feedback = st.form_submit_button("Submit
|
362 |
|
363 |
if submit_feedback and feedback.strip() and feedback2.strip():
|
364 |
# Prepare data to insert
|
@@ -370,7 +370,7 @@ def show_data_collector():
|
|
370 |
"sentiment_feedback": sentiment_feedback,
|
371 |
"emotion_feedback": emotion_feedback
|
372 |
}
|
373 |
-
st.error("
|
374 |
# try:
|
375 |
# from supabase import create_client, Client
|
376 |
# from dotenv import load_dotenv
|
|
|
250 |
col1, col2 = st.columns(2)
|
251 |
with col1:
|
252 |
feedback = st.text_input(
|
253 |
+
"Enter the correct / actual expanded standard formal English text:",
|
254 |
key="feedback_input"
|
255 |
)
|
256 |
with col2:
|
|
|
260 |
)
|
261 |
|
262 |
st.warning(
|
263 |
+
"The correct slider is for the actual probability of the label and wrong slider is the predicted probability by any model which is wrong for that label.")
|
264 |
|
265 |
|
266 |
|
267 |
+
st.write("#### Sentiment Polarity Probabilities (Select values between 0 and 1)")
|
268 |
SENTIMENT_POLARITY_LABELS = ["negative", "neutral", "positive"]
|
269 |
|
270 |
model_names1 = list(MODEL_OPTIONS1.keys())
|
|
|
277 |
sentiment_cols = st.columns(len(SENTIMENT_POLARITY_LABELS))
|
278 |
for idx, label in enumerate(SENTIMENT_POLARITY_LABELS):
|
279 |
with sentiment_cols[idx]:
|
280 |
+
st.write(f"##### **{label.capitalize()}**")
|
281 |
# Create two subcolumns for "Correct" and "Wrong"
|
282 |
subcol_correct, subcol_wrong = st.columns(2)
|
283 |
with subcol_correct:
|
|
|
308 |
# ---------------------------
|
309 |
# Emotion Feedback
|
310 |
# ---------------------------
|
311 |
+
st.write("#### Emotion Probabilities (Select values between 0 and 1)")
|
312 |
EMOTION_MOODTAG_LABELS = [
|
313 |
"anger", "disgust", "fear", "joy", "neutral",
|
314 |
"sadness", "surprise"
|
|
|
331 |
main_cols = st.columns(len(row_labels))
|
332 |
for idx, label in enumerate(row_labels):
|
333 |
with main_cols[idx]:
|
334 |
+
st.write(f"##### **{label.capitalize()}**")
|
335 |
# Create two subcolumns for correct and wrong values.
|
336 |
subcol_correct, subcol_wrong = st.columns(2)
|
337 |
with subcol_correct:
|
|
|
358 |
|
359 |
|
360 |
# Use form_submit_button instead of st.button inside a form
|
361 |
+
submit_feedback = st.form_submit_button("Submit Data")
|
362 |
|
363 |
if submit_feedback and feedback.strip() and feedback2.strip():
|
364 |
# Prepare data to insert
|
|
|
370 |
"sentiment_feedback": sentiment_feedback,
|
371 |
"emotion_feedback": emotion_feedback
|
372 |
}
|
373 |
+
st.error("Submission is disabled in debug logging mode.")
|
374 |
# try:
|
375 |
# from supabase import create_client, Client
|
376 |
# from dotenv import load_dotenv
|
imports.py
CHANGED
@@ -4,7 +4,9 @@ import sys
|
|
4 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), )))
|
5 |
|
6 |
import streamlit as st
|
7 |
-
from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoModel, DebertaV2Tokenizer, DebertaV2ForSequenceClassification
|
|
|
|
|
8 |
# import torch
|
9 |
import numpy as np
|
10 |
import matplotlib.pyplot as plt
|
|
|
4 |
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), )))
|
5 |
|
6 |
import streamlit as st
|
7 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoModel, AutoModelForSeq2SeqLM, DebertaV2Tokenizer, DebertaV2ForSequenceClassification, DebertaV2Model
|
8 |
+
from transformers import pipeline
|
9 |
+
|
10 |
# import torch
|
11 |
import numpy as np
|
12 |
import matplotlib.pyplot as plt
|
pyproject.toml
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
[project]
|
2 |
name = "tachygraphy-microtext-analysis-and-normalization"
|
3 |
-
version = "2025.03.
|
4 |
description = ""
|
5 |
authors = [
|
6 |
{ name = "Archisman Karmakar", email = "[email protected]" },
|
|
|
1 |
[project]
|
2 |
name = "tachygraphy-microtext-analysis-and-normalization"
|
3 |
+
version = "2025.03.26.post1"
|
4 |
description = ""
|
5 |
authors = [
|
6 |
{ name = "Archisman Karmakar", email = "[email protected]" },
|
pyprojectOLD.toml
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
[project]
|
2 |
name = "tachygraphy-microtext-analysis-and-normalization"
|
3 |
-
version = "2025.03.
|
|
|
4 |
# version = "2025.03.22.post1"
|
5 |
# version = "2025.03.21.post1"
|
6 |
# version = "2025.03.18.post5"
|
|
|
1 |
[project]
|
2 |
name = "tachygraphy-microtext-analysis-and-normalization"
|
3 |
+
version = "2025.03.25.post1"
|
4 |
+
# version = "2025.03.24.post1"
|
5 |
# version = "2025.03.22.post1"
|
6 |
# version = "2025.03.21.post1"
|
7 |
# version = "2025.03.18.post5"
|
stacked_stacking_stages/stacking_stages.py
CHANGED
@@ -347,9 +347,9 @@ def get_sentiment_emotion_graph_code(input_text, normalized_text, sentiment_arra
|
|
347 |
penwidth_map[label] = 5
|
348 |
else:
|
349 |
# For three distinct probabilities, assign 1 to the smallest, 3 to the middle, 5 to the largest.
|
350 |
-
penwidth_map[sentiment_sorted[0][0]] =
|
351 |
-
penwidth_map[sentiment_sorted[1][0]] = 3
|
352 |
-
penwidth_map[sentiment_sorted[2][0]] =
|
353 |
|
354 |
# Build the basic Graphviz structure
|
355 |
graph_code = f'''
|
@@ -358,9 +358,9 @@ def get_sentiment_emotion_graph_code(input_text, normalized_text, sentiment_arra
|
|
358 |
node [shape=box, style="rounded,filled", fontname="Helvetica", fontsize=12];
|
359 |
|
360 |
Input [label="Input Text:\\n{input_text.replace('"', '\\"')}", fillcolor="#ffe6de", fontcolor="#000000"];
|
361 |
-
Normalized [label="Normalized Text:\\n{normalized_text.replace('"', '\\"')}", fillcolor="#
|
362 |
-
Sentiment [label="Sentiment"];
|
363 |
-
Emotion [label="Emotion"];
|
364 |
|
365 |
Input -> Normalized;
|
366 |
Input -> Sentiment;
|
@@ -370,7 +370,7 @@ def get_sentiment_emotion_graph_code(input_text, normalized_text, sentiment_arra
|
|
370 |
# Add sentiment nodes (displaying full values without truncation)
|
371 |
for label, prob in sentiment_pairs:
|
372 |
node_id = f"S_{label}"
|
373 |
-
graph_code += f'\n {node_id} [label="{label}: {prob}", fillcolor="#
|
374 |
graph_code += f'\n Sentiment -> {node_id};'
|
375 |
|
376 |
# Add emotion nodes (displaying full values)
|
@@ -378,7 +378,7 @@ def get_sentiment_emotion_graph_code(input_text, normalized_text, sentiment_arra
|
|
378 |
if i < len(emotion_flat):
|
379 |
prob = emotion_flat[i]
|
380 |
node_id = f"E_{label}"
|
381 |
-
graph_code += f'\n {node_id} [label="{label}: {prob}", fillcolor="#
|
382 |
graph_code += f'\n Emotion -> {node_id};'
|
383 |
|
384 |
# Add arrows from each sentiment node to the Emotion node with fixed penwidth based on ranking
|
@@ -605,7 +605,7 @@ def show_stacking_stages():
|
|
605 |
|
606 |
# Text input with change detection
|
607 |
user_input = st.text_input(
|
608 |
-
"Enter text for
|
609 |
)
|
610 |
|
611 |
if st.session_state.get("last_processed_input", "") != user_input:
|
|
|
347 |
penwidth_map[label] = 5
|
348 |
else:
|
349 |
# For three distinct probabilities, assign 1 to the smallest, 3 to the middle, 5 to the largest.
|
350 |
+
penwidth_map[sentiment_sorted[0][0]] = 0.2
|
351 |
+
penwidth_map[sentiment_sorted[1][0]] = 0.3
|
352 |
+
penwidth_map[sentiment_sorted[2][0]] = 1
|
353 |
|
354 |
# Build the basic Graphviz structure
|
355 |
graph_code = f'''
|
|
|
358 |
node [shape=box, style="rounded,filled", fontname="Helvetica", fontsize=12];
|
359 |
|
360 |
Input [label="Input Text:\\n{input_text.replace('"', '\\"')}", fillcolor="#ffe6de", fontcolor="#000000"];
|
361 |
+
Normalized [label="Normalized Text:\\n{normalized_text.replace('"', '\\"')}", fillcolor="#f8ffde", fontcolor="#000000"];
|
362 |
+
Sentiment [label="Sentiment", fillcolor="#ffefde", fontcolor="black"];
|
363 |
+
Emotion [label="Emotion", fillcolor="#ffefde", fontcolor="black"];
|
364 |
|
365 |
Input -> Normalized;
|
366 |
Input -> Sentiment;
|
|
|
370 |
# Add sentiment nodes (displaying full values without truncation)
|
371 |
for label, prob in sentiment_pairs:
|
372 |
node_id = f"S_{label}"
|
373 |
+
graph_code += f'\n {node_id} [label="{label}: {prob}", fillcolor="#f6edfc", fontcolor="black"];'
|
374 |
graph_code += f'\n Sentiment -> {node_id};'
|
375 |
|
376 |
# Add emotion nodes (displaying full values)
|
|
|
378 |
if i < len(emotion_flat):
|
379 |
prob = emotion_flat[i]
|
380 |
node_id = f"E_{label}"
|
381 |
+
graph_code += f'\n {node_id} [label="{label}: {prob}", fillcolor="#edfcef", fontcolor="black"];'
|
382 |
graph_code += f'\n Emotion -> {node_id};'
|
383 |
|
384 |
# Add arrows from each sentiment node to the Emotion node with fixed penwidth based on ranking
|
|
|
605 |
|
606 |
# Text input with change detection
|
607 |
user_input = st.text_input(
|
608 |
+
"Enter text for all in one inference:", key="user_input_stage3", on_change=on_text_change
|
609 |
)
|
610 |
|
611 |
if st.session_state.get("last_processed_input", "") != user_input:
|
transformation_and_Normalization/transformationNormalization_main.py
CHANGED
@@ -351,7 +351,7 @@ def transform_and_normalize():
|
|
351 |
|
352 |
# Text input with change detection
|
353 |
user_input = st.text_input(
|
354 |
-
"Enter text for
|
355 |
)
|
356 |
|
357 |
if st.session_state.get("last_processed_input", "") != user_input:
|
|
|
351 |
|
352 |
# Text input with change detection
|
353 |
user_input = st.text_input(
|
354 |
+
"Enter text for normalization:", key="user_input_stage3", on_change=on_text_change
|
355 |
)
|
356 |
|
357 |
if st.session_state.get("last_processed_input", "") != user_input:
|