Repository navigation
Fix the order of the spacing rules for brackets and symbols in Joiner - #278
Conversation
`isSpaceInsertable` tested `l == sso || l == ssc` only after the rule that inserts a space in front of every SL or SN, so an opening bracket kept a space when the next morpheme was alphabetic or numeric. `(` + `mike` was joined as `( mike)` while `(` + `가` was already joined as `(가`. The bracket exception now sits with the other left-hand exceptions, above that rule, so it no longer depends on what follows the bracket. The symbol rules were asymmetric in the same way. A space was inserted in front of SW but never after it, because `l == sw` already returned false, so `SN SW SN` was joined as `3 +4`, which is neither `3 + 4` nor `3+4`. A symbol that follows a number is attached to it in Korean writing (`9%`, `30℃`, `100$`), so SN followed by SW is now joined without a space, next to the existing `SN` + `NNB` exception. Both cases come from bab2min/kiwipiepy#220. The remaining case in that report, `1` + `인` joined as `1 인`, is not a Joiner rule problem: numeral units tagged NNB (`3등`, `10위`, `3명`) are already attached, and only the ones tagged NNG (`인`, `층`, `팀`, `급`) are not, so it is left alone here. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The test covers the two combinations that were reported broken, the cases that must keep their space (a bracket that follows a word, a symbol that follows a Hangul noun), and a round trip of whole sentences through `analyze` and `Joiner`, which is how the report was written. Without the previous commit the test fails on eight assertions. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe joiner consolidates punctuation checks and prevents spaces between numeric tags and ChangesJoiner spacing correction
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The joiner now keeps numeric-symbol pairs attached while preserving bracket and Hangul spacing, with focused round-trip coverage and no merge-blocking risk identified. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@heeoneie 좋은 기여 해주심에 감사드립니다. |
bab2min/kiwipiepy#220에서 보고된
join의 띄어쓰기 문제 중 두 가지를 고칩니다.재현
0.23.2에서도 재현됩니다. 다만
join에Token객체를 그대로 넘기면 원문의 위치 정보로띄어쓰기가 복원되기 때문에,
(형태, 품사)튜플로 넘길 때만 드러납니다.원인
isSpaceInsertable의 규칙 두 쌍이 서로 모순돼 있었습니다.1. 여는 괄호 뒤
l == sso || l == ssc예외가 "SL이나 SN 앞에는 공백을 넣는다" 규칙보다 아래에 있어서,괄호 뒤에 오는 것이 영문·숫자일 때만 공백이 들어갔습니다.
(+mike(SL)( mike(+1(SN)( 1(+가(NNG)(가괄호 예외를 다른 좌측 예외들(
xpn,so,ss,sw)과 같은 자리로 옮겨, 뒤에 무엇이오든 동일하게 동작하도록 했습니다.
2. 숫자 뒤 기호
SW 앞에는 공백을 넣으면서 SW 뒤에는 넣지 않았습니다(
l == sw가 이미 false를반환). 그래서
SN SW SN은3 +4가 되는데, 이는3 + 4도3+4도 아닙니다.국어 표기에서 숫자에 뒤따르는 기호는 붙여 쓰므로(
9%,30℃,100$), 기존SN+NNB예외 옆에SN+SW를 추가했습니다.고치지 않은 것
같은 보고에 있는
1+인→1 인은 Joiner 규칙의 문제가 아니라고 보아 그대로두었습니다. 숫자 뒤 단위명사는 NNB로 태깅되면 이미 붙습니다.
3등,10위,5번,3명,2년,4월,1시,6개1 인,5 층,2 팀,7 급,3 배,1 종즉 차이는 Joiner가 아니라 해당 형태를 NNB로 보느냐 NNG로 보느냐에서 생깁니다.
또한 별도 모듈인
Kiwi::space()도1인이상→1 인 이상을 내놓아 두 모듈의 동작이일치하고 있어, 한쪽만 바꾸면 오히려 불일치가 생깁니다.
isSpaceInsertable은GenerativeMADataset의 학습 데이터 생성에도 쓰이므로 이 부분은 임의로 건드리지않았습니다. 관련 조사 내용은 이슈 쪽에 코멘트로 남겨두겠습니다.
테스트
TEST(KiwiCpp, IssueP220)을 추가했습니다. 보고된 두 조합, 공백이 유지되어야 하는경우(단어 뒤의 여는 괄호, 한글 뒤의 기호), 그리고 문장을
analyze→Joiner로다시 이어 원문이 복원되는지를 함께 확인합니다.
Fix the order ...) 없이 이 테스트는 8개 단언에서 실패합니다.kiwi-test전체를 돌렸습니다.수정 전 163개 통과 → 수정 후 164개 전부 통과.
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
9%and30℃.Tests