From cce5469dc2df7bb068dae1e3624a2161f3fcf923 Mon Sep 17 00:00:00 2001 From: "Claude (owner)" Date: Fri, 15 May 2026 00:23:42 +0900 Subject: [PATCH] =?UTF-8?q?music=5Fquiz:=20answer=20=EC=A0=95=EA=B7=9C?= =?UTF-8?q?=ED=99=94=20=EB=8F=84=EC=9E=85=20(=EB=8C=80=EC=86=8C=EB=AC=B8?= =?UTF-8?q?=EC=9E=90/=EA=B3=B5=EB=B0=B1=20=EB=AC=B4=EC=8B=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - mq:answer/normalize: storage 의 norm.in 을 한 글자씩 떼어내 소문자화 + 공백 제거 후 norm.acc 에 누적. char 단위 반복은 'data modify ... set string from ... ' (1.20+) 로, 결합은 매크로 ($(acc)$(c)) 로 수행하는 pure-datapack 구현. - process: 큐의 text 를 정규화한 결과를 judge.input 으로 사용 - judge: answer.title 정규화 후 judge.answer 로 사용 - iter_aliases: alias 각 항목 정규화 후 비교 원본 songs.mcfunction 의 title/alias 표기는 그대로 유지 (display 및 정규화 입력으로 모두 사용됨). 입력이 'Lose My Mind' / 'lose my mind' / 'LOSEMYMIND' / 'losemymind' 어떤 형태든 동일한 정규형으로 떨어져 매치. --- .../function/answer/iter_aliases.mcfunction | 4 +- .../data/mq/function/answer/judge.mcfunction | 6 ++- .../mq/function/answer/normalize.mcfunction | 13 +++++ .../answer/normalize/append.mcfunction | 3 ++ .../function/answer/normalize/step.mcfunction | 47 +++++++++++++++++++ .../mq/function/answer/process.mcfunction | 6 ++- 6 files changed, 75 insertions(+), 4 deletions(-) create mode 100644 music_quiz/data/mq/function/answer/normalize.mcfunction create mode 100644 music_quiz/data/mq/function/answer/normalize/append.mcfunction create mode 100644 music_quiz/data/mq/function/answer/normalize/step.mcfunction diff --git a/music_quiz/data/mq/function/answer/iter_aliases.mcfunction b/music_quiz/data/mq/function/answer/iter_aliases.mcfunction index c6a80c4..0ae5d49 100644 --- a/music_quiz/data/mq/function/answer/iter_aliases.mcfunction +++ b/music_quiz/data/mq/function/answer/iter_aliases.mcfunction @@ -2,7 +2,9 @@ execute store result score alen func.temp run data get storage mq:tmp aliases execute if score alen func.temp matches 0 run return 0 -data modify storage mq:tmp judge.answer set from storage mq:tmp aliases[0] +data modify storage mq:tmp norm.in set from storage mq:tmp aliases[0] +function mq:answer/normalize +data modify storage mq:tmp judge.answer set from storage mq:tmp norm.acc function mq:answer/macro/match with storage mq:tmp judge data remove storage mq:tmp aliases[0] diff --git a/music_quiz/data/mq/function/answer/judge.mcfunction b/music_quiz/data/mq/function/answer/judge.mcfunction index 3f7e298..31a898c 100644 --- a/music_quiz/data/mq/function/answer/judge.mcfunction +++ b/music_quiz/data/mq/function/answer/judge.mcfunction @@ -2,8 +2,10 @@ # 매치되면 @s answer = 1 → check_answer 가 정답처리 흐름으로 진입 # 매치 안되면 @s answer = 2 → check_answer 가 reset 처리 (1회 비교 후 초기화) -# 1) 제목과 비교 -data modify storage mq:tmp judge.answer set from storage mq:main answer.title +# 1) 제목과 비교 (정규화 후) +data modify storage mq:tmp norm.in set from storage mq:main answer.title +function mq:answer/normalize +data modify storage mq:tmp judge.answer set from storage mq:tmp norm.acc function mq:answer/macro/match with storage mq:tmp judge # 2) 제목 매치 실패 시 alias 들과 순차 비교 (조기 종료) diff --git a/music_quiz/data/mq/function/answer/normalize.mcfunction b/music_quiz/data/mq/function/answer/normalize.mcfunction new file mode 100644 index 0000000..5e88cfe --- /dev/null +++ b/music_quiz/data/mq/function/answer/normalize.mcfunction @@ -0,0 +1,13 @@ +# 입력 문자열 정규화 — 소문자 변환 + 공백 제거 (대소문자/공백 무시 비교용) +# +# 입력 : storage mq:tmp norm.in (원본 문자열) +# 출력 : storage mq:tmp norm.acc (정규화 결과) +# +# 호출 예: +# data modify storage mq:tmp norm.in set from storage mq:main answer.title +# function mq:answer/normalize +# # 이후 storage mq:tmp norm.acc 에 결과 +# +# 동작: norm.in 을 한 글자씩 떼어내며 normalize/step 으로 재귀 +data modify storage mq:tmp norm.acc set value "" +function mq:answer/normalize/step diff --git a/music_quiz/data/mq/function/answer/normalize/append.mcfunction b/music_quiz/data/mq/function/answer/normalize/append.mcfunction new file mode 100644 index 0000000..e6908cb --- /dev/null +++ b/music_quiz/data/mq/function/answer/normalize/append.mcfunction @@ -0,0 +1,3 @@ +# acc 끝에 c 를 매크로로 concat +# 매크로 인자: storage mq:tmp norm → $(acc), $(c) +$data modify storage mq:tmp norm.acc set value "$(acc)$(c)" diff --git a/music_quiz/data/mq/function/answer/normalize/step.mcfunction b/music_quiz/data/mq/function/answer/normalize/step.mcfunction new file mode 100644 index 0000000..2a01dfd --- /dev/null +++ b/music_quiz/data/mq/function/answer/normalize/step.mcfunction @@ -0,0 +1,47 @@ +# normalize 의 1-문자 처리 + 재귀 스텝 +# 사전조건: storage mq:tmp norm.in 비어있지 않을 수 있음 / norm.acc 누적값 + +execute store result score n.len func.temp run data get storage mq:tmp norm.in +execute if score n.len func.temp matches 0 run return 0 + +# 머리글자 추출 → norm.c +data modify storage mq:tmp norm.c set string from storage mq:tmp norm.in 0 1 + +# 공백 제거 (스킵) +execute if data storage mq:tmp norm{c:" "} run data modify storage mq:tmp norm.c set value "" + +# 대문자 A-Z → 소문자 a-z +execute if data storage mq:tmp norm{c:"A"} run data modify storage mq:tmp norm.c set value "a" +execute if data storage mq:tmp norm{c:"B"} run data modify storage mq:tmp norm.c set value "b" +execute if data storage mq:tmp norm{c:"C"} run data modify storage mq:tmp norm.c set value "c" +execute if data storage mq:tmp norm{c:"D"} run data modify storage mq:tmp norm.c set value "d" +execute if data storage mq:tmp norm{c:"E"} run data modify storage mq:tmp norm.c set value "e" +execute if data storage mq:tmp norm{c:"F"} run data modify storage mq:tmp norm.c set value "f" +execute if data storage mq:tmp norm{c:"G"} run data modify storage mq:tmp norm.c set value "g" +execute if data storage mq:tmp norm{c:"H"} run data modify storage mq:tmp norm.c set value "h" +execute if data storage mq:tmp norm{c:"I"} run data modify storage mq:tmp norm.c set value "i" +execute if data storage mq:tmp norm{c:"J"} run data modify storage mq:tmp norm.c set value "j" +execute if data storage mq:tmp norm{c:"K"} run data modify storage mq:tmp norm.c set value "k" +execute if data storage mq:tmp norm{c:"L"} run data modify storage mq:tmp norm.c set value "l" +execute if data storage mq:tmp norm{c:"M"} run data modify storage mq:tmp norm.c set value "m" +execute if data storage mq:tmp norm{c:"N"} run data modify storage mq:tmp norm.c set value "n" +execute if data storage mq:tmp norm{c:"O"} run data modify storage mq:tmp norm.c set value "o" +execute if data storage mq:tmp norm{c:"P"} run data modify storage mq:tmp norm.c set value "p" +execute if data storage mq:tmp norm{c:"Q"} run data modify storage mq:tmp norm.c set value "q" +execute if data storage mq:tmp norm{c:"R"} run data modify storage mq:tmp norm.c set value "r" +execute if data storage mq:tmp norm{c:"S"} run data modify storage mq:tmp norm.c set value "s" +execute if data storage mq:tmp norm{c:"T"} run data modify storage mq:tmp norm.c set value "t" +execute if data storage mq:tmp norm{c:"U"} run data modify storage mq:tmp norm.c set value "u" +execute if data storage mq:tmp norm{c:"V"} run data modify storage mq:tmp norm.c set value "v" +execute if data storage mq:tmp norm{c:"W"} run data modify storage mq:tmp norm.c set value "w" +execute if data storage mq:tmp norm{c:"X"} run data modify storage mq:tmp norm.c set value "x" +execute if data storage mq:tmp norm{c:"Y"} run data modify storage mq:tmp norm.c set value "y" +execute if data storage mq:tmp norm{c:"Z"} run data modify storage mq:tmp norm.c set value "z" + +# acc = acc + c (매크로 결합) +function mq:answer/normalize/append with storage mq:tmp norm + +# 나머지로 진행 +data modify storage mq:tmp norm.in set string from storage mq:tmp norm.in 1 + +function mq:answer/normalize/step diff --git a/music_quiz/data/mq/function/answer/process.mcfunction b/music_quiz/data/mq/function/answer/process.mcfunction index c77bd65..aac07d0 100644 --- a/music_quiz/data/mq/function/answer/process.mcfunction +++ b/music_quiz/data/mq/function/answer/process.mcfunction @@ -5,7 +5,11 @@ execute if score qlen func.temp matches 0 run return 0 # 첫번째 항목 = 가장 먼저 제출된 것 data modify storage mq:tmp judge set value {input:"", answer:""} -data modify storage mq:tmp judge.input set from storage mq:input queue[0].text + +# 입력 정규화 (소문자 + 공백제거) — 정답과 비교는 둘 다 정규화된 형태로 +data modify storage mq:tmp norm.in set from storage mq:input queue[0].text +function mq:answer/normalize +data modify storage mq:tmp judge.input set from storage mq:tmp norm.acc # 매크로로 해당 seq 를 가진 플레이어 찾아서 judge 실행 data modify storage mq:tmp _find set value {seq:0}