Spaces:
Sleeping
Sleeping
Intention commited on
Commit ·
1d5a27d
1
Parent(s): b6b1f02
app.py
CHANGED
|
@@ -110,16 +110,26 @@ if uploaded_file:
|
|
| 110 |
# Scrub + Sentiment
|
| 111 |
# -----------------------------
|
| 112 |
cleaner = scrubadub.Scrubber()
|
| 113 |
-
convo_df["redacted"] = convo_df["content"].apply(lambda x: cleaner.clean(str(x)))
|
| 114 |
-
|
| 115 |
analyzer = SentimentIntensityAnalyzer()
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
|
| 118 |
# -----------------------------
|
| 119 |
# Inline PII Editing
|
| 120 |
# -----------------------------
|
| 121 |
st.subheader(f"💬 Conversation: {selected_title}")
|
| 122 |
-
|
| 123 |
for i, row in convo_df.iterrows():
|
| 124 |
st.markdown(f"**{row['role'].capitalize()} ({row['create_time']}):**")
|
| 125 |
edited_text = st.text_area(
|
|
@@ -127,12 +137,12 @@ if uploaded_file:
|
|
| 127 |
value=row["redacted"],
|
| 128 |
key=f"edit_{i}"
|
| 129 |
)
|
| 130 |
-
|
| 131 |
**row,
|
| 132 |
"redacted": edited_text
|
| 133 |
})
|
| 134 |
|
| 135 |
-
convo_df = pd.DataFrame(
|
| 136 |
st.dataframe(convo_df[["role", "redacted", "sentiment", "create_time"]])
|
| 137 |
|
| 138 |
# -----------------------------
|
|
|
|
| 110 |
# Scrub + Sentiment
|
| 111 |
# -----------------------------
|
| 112 |
cleaner = scrubadub.Scrubber()
|
|
|
|
|
|
|
| 113 |
analyzer = SentimentIntensityAnalyzer()
|
| 114 |
+
|
| 115 |
+
redacted_rows = []
|
| 116 |
+
for i, row in convo_df.iterrows():
|
| 117 |
+
original_text = str(row["content"])
|
| 118 |
+
redacted_text = cleaner.clean(original_text)
|
| 119 |
+
sentiment_score = analyzer.polarity_scores(original_text)["compound"]
|
| 120 |
+
redacted_rows.append({
|
| 121 |
+
**row,
|
| 122 |
+
"redacted": redacted_text,
|
| 123 |
+
"sentiment": sentiment_score
|
| 124 |
+
})
|
| 125 |
+
|
| 126 |
+
convo_df = pd.DataFrame(redacted_rows)
|
| 127 |
|
| 128 |
# -----------------------------
|
| 129 |
# Inline PII Editing
|
| 130 |
# -----------------------------
|
| 131 |
st.subheader(f"💬 Conversation: {selected_title}")
|
| 132 |
+
edited_rows = []
|
| 133 |
for i, row in convo_df.iterrows():
|
| 134 |
st.markdown(f"**{row['role'].capitalize()} ({row['create_time']}):**")
|
| 135 |
edited_text = st.text_area(
|
|
|
|
| 137 |
value=row["redacted"],
|
| 138 |
key=f"edit_{i}"
|
| 139 |
)
|
| 140 |
+
edited_rows.append({
|
| 141 |
**row,
|
| 142 |
"redacted": edited_text
|
| 143 |
})
|
| 144 |
|
| 145 |
+
convo_df = pd.DataFrame(edited_rows)
|
| 146 |
st.dataframe(convo_df[["role", "redacted", "sentiment", "create_time"]])
|
| 147 |
|
| 148 |
# -----------------------------
|