fix(m02-df): 자재 찾기 띄어쓰기 지우고 비교 · 선 규칙 화면(Rule.ts) = 서버 시험

- /materials — 품목 글(이름 · 규격 · 키 · 원문번호) · 찾는 낱말 모두 띄어쓰기를 지우고 포함(AND) — 「흄관 300」 3 → 8 · 「흄관」 45 → 117
- 시험 — 이름 속 띄어쓰기 · Rule.ts 를 Node 로 그대로 돌려 서버 apply_rule 과 25가지 맞댐(표 찾기 범위 · 숫자 하나 = 같음 · 여럿 · 없음 · 조건 · 바꾸기 · 끝수)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KmELpdXFDRZHhfbGuRhSmL
This commit is contained in:
2026-10-01 20:15:34 +09:00
co-authored by Claude Opus 5.5
parent 226e6c305d
commit 609dd98fe2
2 changed files with 96 additions and 6 deletions
+7 -6
View File
@@ -298,18 +298,19 @@ def _squash(text: Any) -> str:
def _found(sub: str, detail: str, q: str) -> list[dict]:
"""범위(구분 · 상세구분) 안 · 띄어쓰기로 나눈 말을 모두(AND) 이름 · 규격 · 키 · 원문번호에서."""
words = [w.lower() for w in str(q or "").split()]
"""범위(구분 · 상세구분) 안 · 띄어쓰기로 나눈 말을 모두(AND) 이름 · 규격 · 키 · 원문번호에서.
품목 글 · 찾는 낱말 모두 띄어쓰기를 지우고 비교 — 「흄 관(B형)」 도 「흄관」 으로 걸림.
"""
words = [_squash(w) for w in str(q or "").split()]
numbers = _numbers()
rows = (store.loaded()[0].get(MATERIALS) or {}).get("줄") or []
out = []
for r in rows:
if (sub and r.get("구분") != sub) or (detail and r.get("상세구분") != detail):
continue
hay = " ".join(
str(x or "")
for x in (r.get("이름"), r.get("규격"), r.get("키"), numbers.get(r.get("키")))
).lower()
fields = (r.get("이름"), r.get("규격"), r.get("키"), numbers.get(r.get("키")))
hay = "|".join(_squash(x) for x in fields)
if all(w in hay for w in words):
out.append(r)
return out