Upload report_generator.py
Browse files- report/report_generator.py +43 -0
report/report_generator.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# report/report_generator.py
|
| 2 |
+
import json
|
| 3 |
+
|
| 4 |
+
def generate_text_report(conflict_initiator, spikes_by_speaker, per_utt_log, future_alerts):
|
| 5 |
+
"""
|
| 6 |
+
ํ
์คํธ ๋ฆฌํฌํธ ์์ฑ (์ฝ์/Gradio ํ
์คํธ ์ถ๋ ฅ์ฉ)
|
| 7 |
+
"""
|
| 8 |
+
lines = []
|
| 9 |
+
lines.append("๐งพ ๊ฐ๋ฑ ๋ถ์ ๋ฆฌํฌํธ")
|
| 10 |
+
lines.append("-" * 40)
|
| 11 |
+
lines.append(f"๊ฐ๋ฑ ์ ๋ฐ์(์ถ์ ): {conflict_initiator or 'ํ๋จ ๋ถ๊ฐ'}")
|
| 12 |
+
lines.append("")
|
| 13 |
+
|
| 14 |
+
lines.append("๐ ๊ฐ์ ๊ธ๋ณ ์์ฝ(Z-score):")
|
| 15 |
+
if not spikes_by_speaker:
|
| 16 |
+
lines.append(" (๊ธ๋ณ ์์ ์์)")
|
| 17 |
+
else:
|
| 18 |
+
for speaker, spikes in spikes_by_speaker.items():
|
| 19 |
+
lines.append(f" - {speaker}:")
|
| 20 |
+
for idx, score, z in spikes:
|
| 21 |
+
lines.append(f" โข {idx+1}๋ฒ์งธ ๋ฐํ์์ ๊ธ๋ณ ๊ฐ์ง | ์ ์={score:.1f}, z={z}")
|
| 22 |
+
|
| 23 |
+
lines.append("")
|
| 24 |
+
lines.append("๐ฎ ์์ธก ๊ธฐ๋ฐ ๊ฒฝ๊ณ :")
|
| 25 |
+
if not future_alerts:
|
| 26 |
+
lines.append(" (๊ฒฝ๊ณ ์์)")
|
| 27 |
+
else:
|
| 28 |
+
for speaker, alerts in future_alerts.items():
|
| 29 |
+
lines.append(f" - {speaker}:")
|
| 30 |
+
for item in alerts:
|
| 31 |
+
lines.append(f" โข {item}")
|
| 32 |
+
|
| 33 |
+
lines.append("")
|
| 34 |
+
lines.append("๐ง ๋ฐํ๋ณ ๊ฐ์ (๋ถ์ ) ๋ก๊ทธ:")
|
| 35 |
+
for row in per_utt_log:
|
| 36 |
+
lines.append(f" {row['utterance_idx']+1}. {row['speaker']}: {row['text']}")
|
| 37 |
+
lines.append(f" ๊ฐ์ : {json.dumps(row['negative_emotions'], ensure_ascii=False)}")
|
| 38 |
+
lines.append("")
|
| 39 |
+
lines.append("โ ๏ธ ์ค๋ฆฌ ๊ณ ์ง:")
|
| 40 |
+
lines.append(" ๋ณธ ์์คํ
์ ๋ํ ๋ด ๊ฐ์ ํ๋ฆ๊ณผ ํต๊ณ์ ๊ธ๋ณ ํจํด์ ๋ฐํ์ผ๋ก ๊ฐ๋ฑ ์ ๋ฐ ๊ฐ๋ฅ์ฑ์ ์ถ์ ํ๋ ์ฐธ๊ณ ์ฉ ๋๊ตฌ์
๋๋ค.")
|
| 41 |
+
lines.append(" ๋ฒ์ ์ฑ
์ ํ๋จ์ ๊ทผ๊ฑฐ๋ก ์ฌ์ฉํ ์ ์์ผ๋ฉฐ, ๋ฐ์ดํฐ ํธํฅ/๋งฅ๋ฝ ์คํด๋ก ์ธํด ์คํ ๊ฐ๋ฅ์ฑ์ด ์์ต๋๋ค.")
|
| 42 |
+
lines.append(" (์ฐธ๊ณ : EU AI Act, IEEE Ethically Aligned Design)")
|
| 43 |
+
return "\n".join(lines)
|