Spaces:
Sleeping
Sleeping
update def analyze_text()
Browse files
app.py
CHANGED
|
@@ -114,50 +114,52 @@ def analyze_text(judul, isi):
|
|
| 114 |
|
| 115 |
detected = set()
|
| 116 |
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
metaphor = is_metaphor(w)
|
| 141 |
|
| 142 |
-
|
| 143 |
-
|
|
|
|
| 144 |
|
| 145 |
-
|
| 146 |
-
log(" β FAIL: event completeness")
|
| 147 |
-
continue
|
| 148 |
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
-
|
| 154 |
-
|
| 155 |
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
|
|
|
| 159 |
|
| 160 |
-
return
|
| 161 |
|
| 162 |
# ======================
|
| 163 |
# GRADIO UI (TIDAK DIUBAH)
|
|
|
|
| 114 |
|
| 115 |
detected = set()
|
| 116 |
|
| 117 |
+
with open("debug.log", "a", encoding="utf-8") as f:
|
| 118 |
+
f.write("\n" + "="*80 + "\n")
|
| 119 |
+
f.write(f"JUDUL: {judul}\n")
|
| 120 |
+
|
| 121 |
+
for w in windows:
|
| 122 |
+
f.write(f"\n[WINDOW]\n{w}\n")
|
| 123 |
+
|
| 124 |
+
for kategori, desc in SEMANTIC_EVENT.items():
|
| 125 |
+
res = classifier(
|
| 126 |
+
w,
|
| 127 |
+
desc,
|
| 128 |
+
hypothesis_template="Teks ini menggambarkan {}."
|
| 129 |
+
)
|
| 130 |
+
score = max(res["scores"])
|
| 131 |
+
threshold = THRESHOLD[kategori]
|
| 132 |
+
|
| 133 |
+
f.write(
|
| 134 |
+
f" - {kategori} | score={score:.3f} | threshold={threshold}\n"
|
| 135 |
+
)
|
| 136 |
+
|
| 137 |
+
if score < threshold:
|
| 138 |
+
f.write(" β FAIL: threshold\n")
|
| 139 |
+
continue
|
|
|
|
| 140 |
|
| 141 |
+
if score < 0.60:
|
| 142 |
+
comp = event_completeness(w)
|
| 143 |
+
meta = is_metaphor(w)
|
| 144 |
|
| 145 |
+
f.write(f" completeness={comp}, metaphor={meta}\n")
|
|
|
|
|
|
|
| 146 |
|
| 147 |
+
if comp < 2:
|
| 148 |
+
f.write(" β FAIL: completeness\n")
|
| 149 |
+
continue
|
| 150 |
+
if meta:
|
| 151 |
+
f.write(" β FAIL: metaphor\n")
|
| 152 |
+
continue
|
| 153 |
|
| 154 |
+
f.write(" β
ACCEPTED\n")
|
| 155 |
+
detected.add(kategori)
|
| 156 |
|
| 157 |
+
usia = rating_usia(detected)
|
| 158 |
+
f.write(f"\nFINAL KATEGORI: {list(detected)}\n")
|
| 159 |
+
f.write(f"RATING USIA: {usia}\n")
|
| 160 |
+
f.write("="*80 + "\n")
|
| 161 |
|
| 162 |
+
return usia, ", ".join(sorted(detected))
|
| 163 |
|
| 164 |
# ======================
|
| 165 |
# GRADIO UI (TIDAK DIUBAH)
|