Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QND7Co43B24zK2P937rdxt
21 lines
761 B
Python
21 lines
761 B
Python
"""찾기 맞춤 — 낱말(띄어 나눔)마다 키 · 원문번호 · 이름 · 옛이름 · 별칭 가운데 하나에 들면 맞음.
|
|
|
|
띄어쓰기 · 대소문자 무시 · 별칭 = 설계자가 로직을 찾는 다른 이름(쉼표로 여럿 · 208-1).
|
|
짝: `ui_template/ui_template_logic_find.ts` `matchLogic`(화면 쪽) ·
|
|
거울 시험 `test_208_1_logic_alias.py`.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
FIELDS = ("키", "원문번호", "이름", "옛이름", "별칭")
|
|
|
|
|
|
def squash(text) -> str:
|
|
return "".join(str(text or "").lower().split())
|
|
|
|
|
|
def hit(row: dict, q: str) -> bool:
|
|
words = [squash(w) for w in str(q or "").split()]
|
|
fields = [squash(row.get(k)) for k in FIELDS]
|
|
return all(any(w in f for f in fields) for w in words)
|