Skip to content

v0.3: n-gram suggestion data + query layer - #3

Closed
mkpoli wants to merge 4 commits into
rust-migrationfrom
v0.3-ngram-data
Closed

v0.3: n-gram suggestion data + query layer#3
mkpoli wants to merge 4 commits into
rust-migrationfrom
v0.3-ngram-data

Conversation

@mkpoli

@mkpoli mkpoli commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Draft — the data + query layer for the suggestion feature. Stacked on #1 (retarget to master after #1 merges). The candidate-window UI (the consumer) is a separate, Windows-side follow-up.

What

  • tools/build_ngrams.py — builds a pruned n-gram table from ainu-corpora (~196k sentences): a 4000-word unigram list + a bigram model (prev word → top-8 next), serialized to data/ngrams.bin (460 KB). Stores aggregate counts only.
  • src/suggest.rs — embeds the table (include_bytes!) and parses it (pure-std, bounds-checked, can't panic on a bad table). API: next_words(prev), default_words(n).

Verified (offline, here)

  • cargo check --target x86_64-pc-windows-msvc green.
  • Standalone host roundtrip on the real table: predictions are linguistically correct —
    • ruwene (17.6k; the evidential copula)
    • a=kor (my-) → yupo / sapo / hapo / ona (kinship terms after a possessive)
    • kamuyne / utar / menoko
  • Unit tests for the parser (synthetic + embedded table).

Next (not in this PR)

Candidate window (ITfCandidateListUIElement) that shows these as katakana via ainconv, wired into the composition flow — Windows UI, needs the v0.2 foundation.

Add tools/build_ngrams.py (builds a pruned unigram + bigram table from ainu-corpora: 4000 unigrams, 12k contexts, 460 KB) and src/suggest.rs which embeds and parses it (pure-std, bounds-checked) exposing next_words()/default_words(). Validated end-to-end: 'ruwe'->'ne', 'a=kor'->kinship terms. The candidate UI consumer lands next. Unit tests included.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a196012e-2f73-4305-81ea-fd406577aeae

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch v0.3-ngram-data

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

mkpoli and others added 2 commits June 15, 2026 04:55
Extend the generator and table to format v2: a (prev2 prev1) -> next trigram model (26k contexts) alongside the bigram model. suggest.rs gains predict(prev2, prev1) with trigram -> bigram backoff. Table grows to 1.3 MB. Verified on the real corpus: 'ruwe ne' -> na/gusu, 'somo ki' -> no/p/wa.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
complete(prefix, n) returns known words starting with the prefix, frequency-ranked (e.g. 'kam' -> kamuy/kamui, 'ay' -> aynu/aynumosir). Rounds out the query API: default words + next-word prediction + completion. Verified on the real corpus.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The n-gram table is derived from the rights-restricted ainu-corpora; per the ainu-llm/ainu-tts posture, corpus-derived artifacts are private-by-default and need a rights/ethics review before release. So: gitignore data/ngrams.bin (now untracked) and have build.rs generate the OUT_DIR table — the real one if a locally generated data/ngrams.bin is present, else an EMPTY table so public builds compile with suggestions disabled. suggest.rs includes from OUT_DIR; the embedded-table test tolerates the empty case. The publish decision for the real table is deferred to a rights review.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mkpoli

mkpoli commented Jun 15, 2026

Copy link
Copy Markdown
Owner Author

Superseded — this branch is fully merged into integration (verified: git merge-base --is-ancestor passes) and shipped in the v0.2.x releases. It also targets a stale base branch. Closing to declutter; no code is lost. The reconciliation of integration into master is being handled separately.

@mkpoli mkpoli closed this Jun 15, 2026
@mkpoli
mkpoli deleted the v0.3-ngram-data branch June 16, 2026 16:22
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