feat(z01): 찾기에서 물결표·가운뎃점·띄어쓰기를 같게 봄 — 원문이 ∼·~ 를 섞어 써 「~」로 치면 0줄이던 것 · 찾기에만 쓰고 열쇠·칸 값은 원문 그대로(갈래 열쇠 흔들림 방지 · 브레인 · 서브 훑기)
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BW6Jdsh18WPtYUR6THZJqn
This commit is contained in:
@@ -517,6 +517,18 @@ def public(row: dict[str, Any]) -> dict[str, Any]:
|
||||
return {k: v for k, v in row.items() if k not in ("@source", "@axis")}
|
||||
|
||||
|
||||
#: 찾기만 같게 보는 글자 — 원문이 물결표·가운뎃점을 여러 벌로 씀(∼ 26 · ~ 8 · ․ · ㆍ) · 자간 공백(「굴 삭 기」).
|
||||
#: ⚠ **찾기에만** 씀 — 열쇠·칸 값은 원문 그대로(손질하면 갈래 열쇠가 갈림 · 브레인 2026-09-17).
|
||||
_SEARCH_SAME = str.maketrans(
|
||||
{"∼": "~", "~": "~", "〜": "~", "․": "·", "ㆍ": "·", "・": "·", "‧": "·"}
|
||||
)
|
||||
|
||||
|
||||
def fold(text: str) -> str:
|
||||
"""찾기 비교용 — 소문자 · 물결표·가운뎃점 한 벌 · 공백 없앰."""
|
||||
return "".join(str(text or "").lower().translate(_SEARCH_SAME).split())
|
||||
|
||||
|
||||
def table(
|
||||
kind: str,
|
||||
page: int = 1,
|
||||
@@ -528,12 +540,12 @@ def table(
|
||||
) -> dict[str, Any]:
|
||||
all_rows = rows(kind)
|
||||
columns = _columns(kind, all_rows)
|
||||
needle = q.strip().lower()
|
||||
needle = fold(q)
|
||||
hits = (
|
||||
[
|
||||
r
|
||||
for r in all_rows
|
||||
if needle in json.dumps(public(r), ensure_ascii=False, default=str).lower()
|
||||
if needle in fold(json.dumps(public(r), ensure_ascii=False, default=str))
|
||||
]
|
||||
if needle
|
||||
else all_rows
|
||||
|
||||
@@ -38,7 +38,9 @@ def _get(client: TestClient, kind: str, **params) -> dict:
|
||||
def test_산림_평평한_잎_목록과_계산_규칙(client: TestClient) -> None:
|
||||
listed = client.get("/api/master-data/base-prices").json()["kinds"]
|
||||
forest = next(i for i in listed if i["kind"] == "work_item_forest")
|
||||
assert forest["group"] == "work_item" and forest["rows"] == 620 # 갈래마다 한 줄 · 헛단위 7줄 뺌(2026-09-17)
|
||||
assert (
|
||||
forest["group"] == "work_item" and forest["rows"] == 620
|
||||
) # 갈래마다 한 줄 · 헛단위 7줄 뺌(2026-09-17)
|
||||
# 상자 이름은 이름표 것 — 영문 키(work_item)로 뜨던 자리(2026-09-17 브레인 ①)
|
||||
assert {i["group"]: i["group_label"] for i in listed} == {
|
||||
"base_price": "기초단가",
|
||||
@@ -240,3 +242,18 @@ def test_총칙_줄은_기본_감춤_전부를_고르면_보임(client: TestClie
|
||||
_get(client, kind, size=1, axis_role="general_provision")["total"]
|
||||
== (counts["general_provision"])
|
||||
)
|
||||
|
||||
|
||||
def test_찾기는_물결표_가운뎃점_띄어쓰기를_같게_봄(client: TestClient) -> None:
|
||||
"""원문이 물결표를 둘(∼·~)로 쓰고 자간 공백이 들쭉날쭉 — 사람이 친 「~」·붙여 쓴 이름으로도 찾힘.
|
||||
⚠ 찾기만 — 줄 값·열쇠는 원문 그대로(서브 훑기 · 브레인 2026-09-17)."""
|
||||
wavy = _get(client, "work_item_forest", size=50, q="2.1∼2.5")["total"]
|
||||
assert wavy >= 1
|
||||
assert _get(client, "work_item_forest", size=50, q="2.1~2.5")["total"] == wavy
|
||||
assert _get(client, "work_item_forest", size=50, q="2.1~2.5")["total"] == wavy
|
||||
rows = _get(client, "work_item_forest", size=50, q="2.1~2.5")["rows"]
|
||||
assert all("~" not in r["@id"] for r in rows) # 열쇠는 손질 안 함
|
||||
spaced = _get(client, "work_item_forest", size=50, q="토사 깍기", axis_role="")["total"]
|
||||
assert (
|
||||
spaced == _get(client, "work_item_forest", size=50, q="토사깍기", axis_role="")["total"] > 0
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user