feat(712-2): 단위 한 벌 master_unit — 별칭 · 개수 묶음 · 결과단위 배 읽기 · 같은 성격 환산 · 근거 글

- 별칭(master_material) · 같은 성격 환산(master_pick) · 결과단위 배 읽기 셋(Store_Combo · Hopyo_Ours · master_basis) · 보이는 꼴 별칭(master_basis) 갈아 끼움 · 엑셀 맞춤(Hopyo_Match)은 master_pick 이름 그대로 이음
- 개수 묶음(개 · EA · 본 · 매) 1:1 — 본 ↔ 개 단위경고 4 줄 사라짐 · 값 같음
- 부피 ↔ 무게 = 단위중량 표 CC000337 고른 줄 받을 때만(기본 줄 없음) · 밀도 · ㎾h 경고 글만
- B08 /1000 · /40 손 식 = 실무 엑셀 G열 식이라 그대로(시험이 같은 값 대조)
- 지킴 시험 test_712_2_unit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-01 16:03:54 +09:00
co-authored by Claude Opus 5.5
parent 6d5b78f83e
commit 881c204ca8
7 changed files with 195 additions and 49 deletions
@@ -15,10 +15,9 @@ import re
from decimal import Decimal
from functools import lru_cache
import master_unit as mu
from check_master_body import section_of
# ponytail: 단위 별칭은 여기 짧은 표 — 712-2 단위 모듈이 서면 그쪽 별칭으로 갈아 끼움
_ALIAS = {"ea": "개", "톤": "ton", "t": "ton", "㎞": "km", "hr": "시간", "min": "분", "㎏": "kg"}
_UNITS = sorted(
(
"㎡ ㎥ ㎢ ㎞ km ㎜ mm ㎝ cm m ha ton 톤 t kg ㎏ 개소 개 본 대 회 조 기 틀 "
@@ -33,11 +32,10 @@ _UNIT_AT_END = re.compile(
)
_HANGUL = re.compile(r"[가-힣]")
_HEAD = re.compile(r"^\(\s*(?:단위\s*:\s*)?([^()]*당[^()]*)\)$") # 원문 머리 줄 「(단위: ㎥당)」
_RESULT = re.compile(r"원\s*/\s*(\d[\d,]*\.?\d*)?\s*([^\s·(\d,.][^\s·(]*)") # 「원/10㎡」
def unit(text: str) -> str:
return _ALIAS.get(text, text)
return mu.shown(text) # 보이는 꼴 별칭 한 벌(712-2 `master_unit`)
def _times(text: str | None) -> Decimal:
@@ -97,7 +95,7 @@ def basis(table: dict) -> dict:
def result_per(result_unit) -> list[tuple[Decimal, str]]:
"""로직 결과단위 분모 — 「원/10㎡」 → [(10, ㎡)] · 여럿이면 여럿."""
return [(_times(n), unit(u)) for n, u in _RESULT.findall(str(result_unit or ""))]
return [(n, unit(u)) for n, u in mu.per(result_unit)]
def _formula_text(row: dict) -> str: