ToolUp.SparseIndices.Cjk 0.22.0

Prefix Reserved
dotnet add package ToolUp.SparseIndices.Cjk --version 0.22.0
                    
NuGet\Install-Package ToolUp.SparseIndices.Cjk -Version 0.22.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ToolUp.SparseIndices.Cjk" Version="0.22.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ToolUp.SparseIndices.Cjk" Version="0.22.0" />
                    
Directory.Packages.props
<PackageReference Include="ToolUp.SparseIndices.Cjk" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ToolUp.SparseIndices.Cjk --version 0.22.0
                    
#r "nuget: ToolUp.SparseIndices.Cjk, 0.22.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ToolUp.SparseIndices.Cjk@0.22.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ToolUp.SparseIndices.Cjk&version=0.22.0
                    
Install as a Cake Addin
#tool nuget:?package=ToolUp.SparseIndices.Cjk&version=0.22.0
                    
Install as a Cake Tool

ToolUp.SparseIndices.Cjk

Character n-gram segmentation ISparseAnalyzer for non-space-delimited scripts — Chinese, Japanese, Korean.

Why

The default analyzer splits text on Unicode letter/digit runs. A CJK sentence contains no spaces, so the whole clause arrives as one term: the document is reachable only by a query that reproduces the clause verbatim. The sparse leg of hybrid retrieval is not degraded on such a corpus — it is inert, and the dense leg carries the whole load without anyone noticing.

This companion segments CJK runs into overlapping n-grams so BM25 has terms to work with, with no dictionary, no model and no native binary.

Install and compose

<PackageReference Include="ToolUp.SparseIndices.Cjk" Version="..." />
open ToolUp.SparseIndices.Cjk

let app =
    RAGServerApp.create factory profile embedder
    |> RAGServerApp.withSparseAnalyzer (CjkAnalyzer.bigrams ())

Or with explicit options:

CjkAnalyzer.create { NGramSize = 2; IncludeUnigrams = true }

Behaviour

東京都の人口 analyses to 東京 / 京都 / 都の / の人 / 人口 — a query for 東京 or 人口 now matches.

Mixed-script text is handled in one pass. Runs are split at the CJK boundary: CJK runs are n-grammed, everything else falls through to the shipped word tokenisation. Windows 11 の設定 yields windows / 11 / の設 / 設定. You do not need a second analyzer for a corpus that mixes languages.

Option Default Effect
NGramSize 2 Width of the sliding window over a CJK run. 1 indexes single characters (close to indexing letters); 3+ misses two-character words, which are most of them.
IncludeUnigrams false Also emit single characters. Buys recall for one-character queries at the cost of long posting lists.

A CJK run shorter than NGramSize always emits its characters, so a single-character token is never dropped.

Posture: production-viable, not best-in-class

Stated plainly, because the alternative is discovering it in production.

What it costs

  • Index size — roughly one posting per character rather than per word; expect the sparse index to grow 2–3× on CJK-heavy corpora.
  • Precision — bigrams cross word boundaries, so the phrase 東京都 also generates 京都, which names a different city. IDF absorbs much of this and RRF fusion with the dense leg absorbs more, but a bigram index does return matches a word segmenter would not.

When to use this: you want CJK retrieval to work today with zero operational surface, or CJK is a secondary language in a mixed corpus.

When to reach past it: CJK is the primary corpus language and precision matters more than deployment simplicity. A dictionary or model-based segmenter (MeCab / Kuromoji for Japanese, jieba for Chinese) produces word tokens, a smaller index and better precision — and carries a dictionary file or a native binary, which is a different companion with a different supply-chain posture. That is deliberately out of scope here; the seam is the same, so such a companion drops in without touching the index.

Pure, deterministic, stateless, no I/O — CompanionCapability.identity, safe in any distributed topology.

See also

  • docs/companions/sparse-analyzers.md — the seam and the symmetry guarantee.
  • ToolUp.SparseIndices.Snowball — stemming / stop words for space-delimited European languages.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.22.0 35 8/27/2026
0.21.0 38 8/26/2026
0.20.1 86 8/20/2026
0.20.0 110 8/19/2026