Spaces:
Sleeping
Sleeping
update def analyze_text()
Browse files113 unmodified lines114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163113 unmodified linesdetected = set()log("=" * 80)log(f"JUDUL: {judul}")for w in windows:log(f"\n[WINDOW]\n{w}")for kategori, desc in SEMANTIC_EVENT.items():res = classifier(w,desc,hypothesis_template="Teks ini menggambarkan {}.")score = max(res["scores"])log(f" - kategori: {kategori}")log(f" score: {round(score, 3)} | threshold: {THRESHOLD[kategori]}")if score < THRESHOLD[kategori]:log(" β FAIL: threshold")continueif score < 0.60:completeness = event_completeness(w)metaphor = is_metaphor(w)log(f" completeness: {completeness}")log(f" metaphor: {metaphor}")if completeness < 2:log(" β FAIL: event completeness")continueif metaphor:log(" β FAIL: metaphor")continuelog(" β ACCEPTED")detected.add(kategori)log(f"\nFINAL KATEGORI: {list(detected)}")log(f"RATING USIA: {rating_usia(detected)}")log("=" * 80)return rating_usia(detected), ", ".join(sorted(detected))# ======================# GRADIO UI (TIDAK DIUBAH)113 unmodified lines114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165113 unmodified linesdetected = set()with open("debug.log", "a", encoding="utf-8") as f:f.write("\n" + "="*80 + "\n")f.write(f"JUDUL: {judul}\n")for w in windows:f.write(f"\n[WINDOW]\n{w}\n")for kategori, desc in SEMANTIC_EVENT.items():res = classifier(w,desc,hypothesis_template="Teks ini menggambarkan {}.")score = max(res["scores"])threshold = THRESHOLD[kategori]f.write(f" - {kategori} | score={score:.3f} | threshold={threshold}\n")if score < threshold:f.write(" β FAIL: threshold\n")continueif score < 0.60:comp = event_completeness(w)meta = is_metaphor(w)f.write(f" completeness={comp}, metaphor={meta}\n")if comp < 2:f.write(" β FAIL: completeness\n")continueif meta:f.write(" β FAIL: metaphor\n")continuef.write(" β ACCEPTED\n")detected.add(kategori)usia = rating_usia(detected)f.write(f"\nFINAL KATEGORI: {list(detected)}\n")f.write(f"RATING USIA: {usia}\n")f.write("="*80 + "\n")return usia, ", ".join(sorted(detected))# ======================# GRADIO UI (TIDAK DIUBAH)
app.py+40-38