Skip to content

feat(tokenizers): add experimental Korean tokenizer#1018

Merged
thatjuan merged 2 commits into
oramasearch:mainfrom
dayongkr:add-korean-tokenizer
Jun 27, 2026
Merged

feat(tokenizers): add experimental Korean tokenizer#1018
thatjuan merged 2 commits into
oramasearch:mainfrom
dayongkr:add-korean-tokenizer

Conversation

@dayongkr

@dayongkr dayongkr commented Feb 16, 2026

Copy link
Copy Markdown
Contributor

Why add Korean support?

@orama/tokenizers currently supports experimental CJK tokenizers for Japanese and
Mandarin, but not Korean.
This makes Korean text search inconsistent compared to other CJK languages.

Adding a Korean tokenizer:

  • enables proper Korean word segmentation for indexing/search
  • keeps language support more consistent across CJK
  • provides an official import path for Korean users (@orama/tokenizers/korean)

What changed

New tokenizer

  • Added packages/tokenizers/src/korean.ts
    • Implements Korean tokenization using Intl.Segmenter("ko", { granularity: "word" })
    • Follows the same structure and behavior as existing Japanese/Mandarin tokenizers

Exports and package wiring

  • Updated packages/tokenizers/src/index.ts
    • Added korean tokenizer export
  • Updated packages/tokenizers/package.json
    • Added ./korean export entries (ESM/CJS types + runtime files)
    • Included Korean test in the package test script
    • Added korean keyword

Tests

  • Added packages/tokenizers/tests/korean.test.ts
    • Validates Korean tokenization/search behavior with Korean city and university names
    • Keeps style aligned with existing Japanese/Mandarin tokenizer tests

dayongkr and others added 2 commits February 16, 2026 14:18
…hitespace coverage

The Korean tokenizer uses Intl.Segmenter('ko', { granularity: 'word' }), which
segments Korean on whitespace (UAX#29). Space-less compounds such as the Hangul
for "Seoul National University" therefore stay a single token and are not split
into "Seoul" + "university" (unlike the Japanese/Mandarin tokenizers, which
dictionary-split their equivalents).

The existing city-name searches already pass because Orama matches the radix
index by prefix (default exact: false), so the city name matches the whole
compound token. Add comments explaining this and two assertions that make the
behavior explicit and regression-proof:
- searching the shared "university" suffix returns 0 hits (compounds are not
  split), the inverse of japanese.test.ts where the suffix matches all three
  universities;
- a space-separated multi-word document is found when searching its middle
  word, proving whitespace word segmentation works.

No tokenizer behavior changed.
@thatjuan thatjuan merged commit d184b20 into oramasearch:main Jun 27, 2026
1 check passed
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.

2 participants