Skip to content

fix(tokenizer): tokenize offset 계산이 다중 공백에서 틀리는 버그 수정#287

Merged
lovit merged 1 commit intorefactor-2026from
feature/280
Mar 10, 2026
Merged

fix(tokenizer): tokenize offset 계산이 다중 공백에서 틀리는 버그 수정#287
lovit merged 1 commit intorefactor-2026from
feature/280

Conversation

@lovit
Copy link
Copy Markdown
Owner

@lovit lovit commented Mar 10, 2026

Summary

  • sentence.split() + offset += len(token) + 1 조합이 연속 공백 시 Token.begin/end 오류를 발생시키던 버그 수정
  • re.finditer(r'\S+', sentence)로 교체하여 각 eojeol의 실제 위치를 직접 추출

변경 전/후

# 변경 전
tokenize('hello  world', return_words=False)
# Token(world, begin=6, ...)  ← 실제 위치는 7  ❌

# 변경 후
tokenize('hello  world', return_words=False)
# Token(world, begin=7, ...)  ✓

관련 이슈

Closes #280

🤖 Generated with Claude Code

sentence.split() + offset += len + 1 방식은 연속 공백 시 Token position 오류.
re.finditer(r'\S+', sentence)로 교체하여 각 eojeol의 실제 시작 위치를 직접 추출.
단위 테스트 추가.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lovit lovit merged commit 013f568 into refactor-2026 Mar 10, 2026
0 of 2 checks passed
lovit added a commit that referenced this pull request Mar 10, 2026
PR #287 병합 시 충돌 마커(<<<<<<< HEAD)가 잘못 포함된 것을 수정

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant