feat(830-10): 불러오기 재료 찾기를 지역 · 상하차 칸에 맞춤 — 가져온 줄 글은 빌더 규칙으로 판독

- 새 M02_Mat_Place: 가져온 이름 · 규격 → (뺀 이름, 뺀 규격, 지역, 상하차)(material_merge 판독 한 벌) · 고르는 차례 rank
- 고르는 차례 = 상하차 맞음(글 없으면 -) › 값 있는 줄 › 줄 지역 › 전국 · 지역 모름 › 서울 › 경기 › 그 밖(값 가운데에 가까운 줄)
- Elem_Alias(_same · one · region_of) · Hopyo_Match(목록에 지역 · 상하차 · 값 · 이름 같음 = 뺀 이름 + 지역 · 상하차 같음) · Hopyo_Material(_places · 변형 지역 = 지역 칸 · _prefer) · MatSame._pick · MatFind 후보 글 = 지역 칸
- 다시 고르기 · 찾기 창 · 줄 풍선말 후보 글에 지역 · 상하차(M01 placeNote 한 벌)
- 시험: 814_1 · m02_hopyo_match 기대를 지역 칸 꼴로 · 새 지킴 test_830_10_material_region 21
- 불러오기 지킴 812_1 · 814_1 · 815_1 · 817_1 · 827_2 · 827_3 · 828_1 · 828_2 · 778_5 ×2 · 793_2 ×2 · 797_1 ×2 · m02_hopyo_match 통과 · typecheck 0

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 20:57:23 +09:00
co-authored by Claude Opus 5.5
parent 98f3ab59cb
commit dd9ebad8d1
12 changed files with 305 additions and 40 deletions
+11 -14
View File
@@ -8,7 +8,7 @@
맞음 = ① 이름 · 규격 같음 하나(`Match._exact`) ② 바탕 이름 · 단위 · 규격 맞음 1 이 한 품목뿐
(지역 · 관급/사급만 다른 변형 = 한 품목 · 같은 단위 먼저 · 줄 글의 관급/사급 먼저 · 없으면
별도계상 줄 = 관급 · 재료비 줄 = 사급).
지역(361-1) = 줄 글에 지역 낱말 → 그 지역 변형(꼬리표 「지역 — 줄 글」) · 없으면 지역 없는
지역(361-1 · 830-10) = 우리 줄은 지역 칸 · 줄 글에 지역 낱말 → 그 지역 변형(꼬리표 「지역 — 줄 글」) · 없으면 지역 없는
변형((전국) 품목) · 그것도 없으면(레미콘) 「전국」 = 키 · 단가 없는 자리표(`national` ·
바탕 이름(전국)-관급/사급 · 규격 · 단위 · 꼬리표 「전국 — 지역은 프로젝트에서」) · 자동 고름 없음 ·
지역 변형은 고르기 창에서 사용자가.
@@ -25,6 +25,7 @@ from functools import lru_cache
from typing import Any
from M02_MasterTemplete import M02_Hopyo_Match as hm
from M02_MasterTemplete import M02_Mat_Place as place
mm = hm.mm
APART = "별도계상"
@@ -55,8 +56,8 @@ def _nfkc(text: Any) -> str:
@lru_cache(maxsize=1)
def _places() -> frozenset[str]:
"""곳 낱말 — M01 레미콘 이름의 지역 · 시군 낱말(자료에서 · 「홍천군」 · 「미원면」)."""
names = (one["이름"] for one in hm.targets()["자재"] if one["이름"].startswith("레미콘("))
"""곳 낱말 — M01 레미콘 줄 지역 칸의 지역 · 시군 낱말(자료에서 · 「홍천군」 · 「미원면」)."""
names = (one["지역"] for one in hm.targets()["자재"] if one["이름"].startswith("레미콘"))
words = {w for n in names for w in re.findall(r"[가-힣]{2,}", _nfkc(n))}
return frozenset(words - {"레미콘", "조합공통품목", *SUPPLY})
@@ -120,7 +121,6 @@ def _pool(got_id: int) -> tuple[list[dict[str, Any]], dict[str, list[dict[str, A
rows, index = [], {}
for at, one in enumerate(hm.targets()["자재"]):
name, spec = _nfkc(one["이름"]), _nfkc(one["규격"])
words = set(re.findall(r"[가-힣]+", name))
row = {
"one": one,
"at": at,
@@ -128,7 +128,7 @@ def _pool(got_id: int) -> tuple[list[dict[str, Any]], dict[str, list[dict[str, A
"nums": _nums(spec),
"ranges": _ranges(spec),
"spec": mm.plain_spec(spec),
"region": sorted(w for w in words if _region(w) and w not in NO_REGION),
"region": sorted(place.words(one["지역"])), # 830-10 지역 칸
"supply": next((w for w in SUPPLY if w in name), None),
"key": (
tuple(sorted(_nums(spec))),
@@ -210,18 +210,15 @@ def _hit(r: dict[str, Any], regions: list[str]) -> bool:
def _prefer(rows: list[dict[str, Any]], line: dict[str, Any]) -> list[dict[str, Any]]:
"""변형 차례 — 줄 글의 관급/사급 · 지역 먼저 · 지역 없는 것 · 엑셀(M01) 차례."""
"""변형 차례 — 줄 글의 관급/사급 › 상하차 › 지역(줄 지역 › 전국 · 지역 없음 › 서울 › 경기 › 값 가운데) ›
엑셀(M01) 차례(`M02_Mat_Place.rank` · 830-10)."""
supply, regions = _wants(line)
load = place.line(line.get("이름"), line.get("규격"))["상하차"]
mid = place.middle([r["one"] for r in rows])
def rank(r: dict[str, Any]) -> tuple:
hit = _hit(r, regions)
return (
supply is not None and r["supply"] not in (None, supply),
bool(regions) and not hit,
bool(r["region"]),
bool(r["region"]) or not any(w in r["one"]["이름"] for w in NO_REGION), # (전국) 먼저
r["at"],
)
*head, gap = place.rank(r["one"], regions, load, mid)
return (supply is not None and r["supply"] not in (None, supply), *head, gap, r["at"])
return sorted(rows, key=rank)