Files
University_Labs_Nego_Agent/server/services/generation/postprocess.py
T
민헌andClaude Opus 5.5 13ab9dee84 chore: 2차년도 성능평가 측정 구성 초기 업로드
data(train 520·holdout 120), server(발화 생성 서버), eval(grounding_eval), run_eval.py·run_test.sh.
logs/ 는 실행 때마다 생기는 기록이라 README.md 만 올리고 나머지는 .gitignore 로 뺀다.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 14:05:48 +09:00

29 lines
1.1 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""생성 결과 정리 — 구매자 발화 하나만 남긴다.
ROUGE 는 표면 어휘를 비교하므로 화자 표시·따옴표·코드펜스·이어 쓴 판매자 발화가 섞이면 점수가 떨어진다.
"""
import re
ROLE_PREFIX_RE = re.compile(r"^\s*(?:\[\s*(?:구매자|MD|바이어)\s*\]|(?:구매자|MD|바이어)\s*[::])\s*")
CUT_MARKERS = ("[판매자]", "판매자:", "판매자 :", "[진행]")
QUOTE_PAIRS = (('"', '"'), ("“", "”"), ("'", "'"), ("‘", "’"))
def clean_utterance(text: str) -> str:
text = (text or "").strip()
if text.startswith("```"):
text = text.strip("`").strip()
for marker in CUT_MARKERS:
idx = text.find(marker)
if idx > 0:
text = text[:idx]
elif idx == 0:
text = ""
text = ROLE_PREFIX_RE.sub("", text.strip())
text = " ".join(line.strip() for line in text.splitlines() if line.strip())
for left, right in QUOTE_PAIRS:
if len(text) >= 2 and text.startswith(left) and text.endswith(right):
text = text[1:-1].strip()
return text