feat(b09): 갈래 느슨한 맞춤·수량 자리 못 맞춤을 로그로 — 조용히 다른 갈래에 붙는 자리 드러냄

- find_variant_code 가 글자 대신 수의 짝·구간으로 고른 자리를 한 번씩 로그(명세 14장 정정, 판정 (나))
- 수량 소수자리는 이름 그대로 두고 종목 이름을 못 맞춘 줄만 로그

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016VBGFXB9AbJBwXP19z75Qq
This commit is contained in:
2026-09-13 22:55:27 +09:00
co-authored by Claude Opus 5
parent d56fa18971
commit 165bfed0a8
3 changed files with 69 additions and 3 deletions
+24 -2
View File
@@ -17,6 +17,7 @@
from __future__ import annotations
import logging
import re
from dataclasses import dataclass, field
from dataclasses import replace as dataclass_replace
@@ -66,6 +67,7 @@ from B09_Estimation.B09_Estimation_WorkItemUnit import unit_of as work_item_unit
from B09_Estimation.B09_Estimation_Rounding import OutputPlace, round_at
from B09_Estimation.B09_Estimation_Transport import parse_distance_km
logger = logging.getLogger(__name__)
_RE_EMPHASIS = re.compile(r"\*\*(.+?)\*\*")
_ZERO = Decimal(0)
#: 연료는 자재 카탈로그에 없어 합성 코드로 세운다 — 코드가 있어야 조인이 성립한다.
@@ -512,14 +514,34 @@ def find_variant_code(
if _numbers_of(normalize_variant_key(code[len(prefix) :])) == numbers
]
if len(hits) == 1:
return hits[0]
return _loose(work_item_code, variant_value, hits[0], "수의 짝")
if len(numbers) == 1:
# 저장 제원이 **한 값**으로 온다(뒷길이 45㎝). 갈래는 구간이므로 그 값을 담는
# 구간을 고른다 — 「45」 → 「55cm이하」. **가장 좁은 구간**을 고른다.
return _bracket_for(numbers[0], candidates, prefix)
picked = _bracket_for(numbers[0], candidates, prefix)
return _loose(work_item_code, variant_value, picked, "구간") if picked else None
return None
#: 느슨한 맞춤을 이미 알린 짝 — 내역을 그릴 때마다 같은 줄이 로그를 채우지 않게.
_LOOSE_LOGGED: set[tuple[str, str, str]] = set()
def _loose(work_item_code: str, variant_value: str, picked: str, how: str) -> str:
"""글자가 아니라 **수·구간으로** 갈래를 고른 자리 — 로그로 남기고 그대로 돌려줌.
⚠ 조용히 다른 갈래에 붙는 자리가 바로 여기라 드러내 둠(명세 14장 정정 · 브레인 판정 (나)).
갈래의 정본은 지금 **B09 단가표 제목**이고 마스터 `variant_key` 는 첫 열만 담아 못 씀(1장 몫).
"""
key = (work_item_code, str(variant_value), picked)
if key not in _LOOSE_LOGGED:
_LOOSE_LOGGED.add(key)
logger.info(
"B09 갈래 느슨한 맞춤(%s): %s 「%s」 → %s", how, work_item_code, variant_value, picked
)
return picked
def _bracket_for(value: Decimal, candidates: list[str], prefix: str) -> str | None:
"""그 값을 담는 갈래 — 「N 이하」는 상한, 「A 이상~B 미만」은 범위로 본다."""
best: tuple[Decimal, str] | None = None