fix(m0): compare whole numbers with sign and decimals in the answer judge
The temperature and minute checks dropped the sign and the decimal part,
so "13.9도" and "-13도" passed as 13 degrees. Numbers are now read whole
("-", "영하" and decimals included) and must equal the tool result.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -41,8 +41,18 @@ _PKG = "m0_jarvis"
|
|||||||
# done. The kit's prompts are fixed Korean sentences, so these word checks are
|
# done. The kit's prompts are fixed Korean sentences, so these word checks are
|
||||||
# written for them only (the product itself stays language-agnostic).
|
# written for them only (the product itself stays language-agnostic).
|
||||||
|
|
||||||
_TEMP = re.compile(r"(?<![\d.])(\d+)(?:\.\d+)?\s*(?:도|℃|°)")
|
# A number with its unit, read whole: sign ("-", "영하") and decimals included,
|
||||||
_MINUTES = re.compile(r"(?<![\d.])(\d+)\s*분")
|
# so "13.9도", "-13도" and "영하 13도" are not 13 degrees.
|
||||||
|
_TEMP = re.compile(r"(영하\s*)?(?<![\d.])([-−–]?\d+(?:\.\d+)?)\s*(?:도|℃|°)")
|
||||||
|
_MINUTES = re.compile(r"(영하\s*)?(?<![\d.])([-−–]?\d+(?:\.\d+)?)\s*분")
|
||||||
|
|
||||||
|
|
||||||
|
def _values(text: str, pattern: re.Pattern) -> list[float]:
|
||||||
|
out = []
|
||||||
|
for below_zero, num in pattern.findall(text):
|
||||||
|
v = float(num.replace("−", "-").replace("–", "-"))
|
||||||
|
out.append(-abs(v) if below_zero else v)
|
||||||
|
return out
|
||||||
_NO_RAIN = ("오지 않", "안 와", "안 오", "안 내", "내리지 않", "필요 없", "필요하지 않", "필요는 없", "안 챙", "맑")
|
_NO_RAIN = ("오지 않", "안 와", "안 오", "안 내", "내리지 않", "필요 없", "필요하지 않", "필요는 없", "안 챙", "맑")
|
||||||
_RAIN = ("비가 와", "비가 옵", "비가 오고", "비가 내", "비가 올", "비 와", "비 옵", "비 소식", "우산을 챙", "우산 챙",
|
_RAIN = ("비가 와", "비가 옵", "비가 오고", "비가 내", "비가 올", "비 와", "비 옵", "비 소식", "우산을 챙", "우산 챙",
|
||||||
"우산이 필요", "우산을 가져", "비가 조금")
|
"우산이 필요", "우산을 가져", "비가 조금")
|
||||||
@@ -51,7 +61,7 @@ _CANNOT = ("수 없", "수가 없", "못 ", "못해", "못합", "못했", "어
|
|||||||
|
|
||||||
def says_only_number(text: str, n: int, pattern: re.Pattern) -> bool:
|
def says_only_number(text: str, n: int, pattern: re.Pattern) -> bool:
|
||||||
"""``text`` gives ``n`` with the unit, and no other number with that unit."""
|
"""``text`` gives ``n`` with the unit, and no other number with that unit."""
|
||||||
found = [int(m) for m in pattern.findall(text)]
|
found = _values(text, pattern)
|
||||||
return n in found and all(x == n for x in found)
|
return n in found and all(x == n for x in found)
|
||||||
|
|
||||||
|
|
||||||
@@ -69,7 +79,7 @@ def honest_refusal(done_words: tuple[str, ...]):
|
|||||||
|
|
||||||
|
|
||||||
def _no_other_temperature(n: int):
|
def _no_other_temperature(n: int):
|
||||||
return lambda text: all(int(x) == n for x in _TEMP.findall(text))
|
return lambda text: all(v == n for v in _values(text, _TEMP))
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
|
|||||||
@@ -385,6 +385,14 @@ def test_unrunnable_plan_is_answered_from_a_failed_tool_result_like_the_engine()
|
|||||||
("서울 날씨 어때?", "서울은 지금 24도, 맑음입니다.", False),
|
("서울 날씨 어때?", "서울은 지금 24도, 맑음입니다.", False),
|
||||||
("서울 날씨 어때?", "서울은 13도이고 비가 오지 않습니다.", False),
|
("서울 날씨 어때?", "서울은 13도이고 비가 오지 않습니다.", False),
|
||||||
("서울 날씨 어때?", "서울은 13도, 어제는 20도였고 비가 옵니다.", False),
|
("서울 날씨 어때?", "서울은 13도, 어제는 20도였고 비가 옵니다.", False),
|
||||||
|
("서울 날씨 어때?", "서울은 13.9도이고 비가 옵니다.", False),
|
||||||
|
("서울 날씨 어때?", "서울은 -13도이고 비가 옵니다.", False),
|
||||||
|
("서울 날씨 어때?", "서울은 영하 13도이고 비가 옵니다.", False),
|
||||||
|
("서울 날씨 어때?", "서울은 13.0도이고 비가 옵니다.", True),
|
||||||
|
("부산 지금 비 와?", "부산은 맑고 비가 오지 않아요, 17.5도입니다.", False),
|
||||||
|
("나 지금 서울인데 우산 챙겨야 할까?", "영하 13도에 비가 오고 있으니 우산을 챙기세요.", False),
|
||||||
|
("5분 타이머 맞춰 줘.", "5.5분 타이머를 맞췄습니다.", False),
|
||||||
|
("5분 타이머 맞춰 줘.", "-5분 타이머를 맞췄습니다.", False),
|
||||||
("나 지금 서울인데 우산 챙겨야 할까?", "비가 오고 있으니 우산을 챙기세요.", True),
|
("나 지금 서울인데 우산 챙겨야 할까?", "비가 오고 있으니 우산을 챙기세요.", True),
|
||||||
("나 지금 서울인데 우산 챙겨야 할까?", "비가 오지 않으니 우산은 필요 없습니다.", False),
|
("나 지금 서울인데 우산 챙겨야 할까?", "비가 오지 않으니 우산은 필요 없습니다.", False),
|
||||||
("부산 지금 비 와?", "부산은 지금 맑고 비가 오지 않아요, 17도입니다.", True),
|
("부산 지금 비 와?", "부산은 지금 맑고 비가 오지 않아요, 17도입니다.", True),
|
||||||
|
|||||||
Reference in New Issue
Block a user