# Alar, repacked: a word list, its phonetics, and a learned ending table

**This is a derived database of Alar, V. Krishna's Kannada–English dictionary.** It is published under the
**Open Database Licence 1.0**, like its source. **Read `NOTICE.md` first** — it names the author, the maintainer, and
what was derived.

| file | what it is | bytes |
| --- | --- | --- |
| `kn-words.txt` | the 140,011 unique headwords, NFC, one per line | 3,250,154 |
| `kn-words.fc.lzma` | the same list, front-coded then lzma | 325,984 |
| `kn-phones.tsv.lzma` | word to the source's phonetic notation | 898,000 |
| `kn-suffixes.tsv` | endings learned from the corpus, with the counts that justify each | 10,998 |

# A Kannada word pack, derived from Alar — and what it does and does not prove
**This folder is a derived database. It is licensed ODbL-1.0, like its source.** It comes from
[`alar-dict/data`](https://github.com/alar-dict/data) — **V. Krishna's Kannada → English dictionary**, maintained by
IDAF with support from Zerodha. **The words are theirs; only the shape is ours.**
| file | what it is | bytes |
| --- | --- | --- |
| `kn-words.txt` | the 140,011 unique headwords, NFC, one per line, LF endings | 3,250,154 |
| `kn-words.fc.lzma` | the same list, front-coded then lzma | **325,984** |
| `kn-phones.tsv.lzma` | word → the source's phonetic notation | 898,000 |
| `kn-suffixes.tsv` | endings learned from the corpus, with the evidence for each | 10,998 |
| `manifest.json` | sizes and SHA-256 | 1,047 |
Rebuild it with `python tools/kannada-lexicon.py build`; measure it with `check` and `learn`.
## How to read the front-coded list
Each record is one byte holding the length of the shared prefix with the previous word, then the rest of the word in
UTF-8, then a newline. Start with an empty previous word. The newline is free because a Kannada UTF-8 stream never
contains the byte `0x0A`.
```python
import lzma
def read_words(path):
data = lzma.decompress(open(path, "rb").read())
prev = b""
for record in data.split(b"\n"):
if not record:
continue
n, rest = record[0], record[1:]
word = prev[:n] + rest
yield word.decode("utf-8")
prev = word
```
The writer is `front_code()` in `tools/kannada-lexicon.py`, and it is the reference if this snippet and it disagree.
## What the words cover, measured on real Kannada
The test text is 6,496 tokens of held-out Kannada sentences (FLEURS `kn_in` test split, second half; the suffix table
was learned on the first half, so nothing was measured on what it learned from).
| | share |
| --- | --- |
| a headword exactly | 34.2 % |
| a headword after removing a learned ending, with sandhi tolerance | 37.3 % |
| **still unknown — a guard would flag these** | **28.5 %** |
**So the pack is a good lexicon and not yet a guard.** The 28.5 % is not noise: it is function words (`ಹಾಗೂ`,
`ಯಾವುದೇ`, `ಆದ`), verb forms built with sandhi (`ಕರೆಯಲಾಗುತ್ತದೆ`, `ಆಗಿದೆ`), and proper nouns and loanwords
(`ಸೌತ್`, `ಗ್ರೇಟ್`, `ಪಿರಮಿಡ್`, `ಷೆಂಗೆನ್`). **A red underline on three words in ten is worse than no underline.**
## What it is good for today
1. **"Sounds like" repair** for the recogniser: when the ear emits a token outside the speaker's own vocabulary, the
word list plus the phonetics give a bounded candidate set. Precision comes from the bound, not from the list.
2. **A meaning check for the translator**: every word carries English glosses, so a translation that shares no content
word with the source's glosses can be flagged without a model.
3. **The endings themselves**: 529 endings with the count and the distinct stems that justify each one. That table is a
description of Kannada morphology derived from evidence rather than typed by hand.
## The one trap in the source file
In `alar.yml` the field **`head:` is the filing letter** (49 distinct values) and the word itself is in **`entry:`**.
A first pass that counts `head:` reports 50 words and looks plausible. It cost this project one wrong measurement.

## Reading the front-coded list (`kn-words.fc.lzma`)

**One record per line: a single byte holding the shared prefix length, offset by `0x40`, then the rest of the word in
UTF-8, then a newline.** The prefix length is counted in **bytes**, not characters. Start with an empty previous word.
The newline is safe as a delimiter because a Kannada UTF-8 stream never contains the byte `0x0A`.

```python
import lzma

prev = b""
words = []
with lzma.open("kn-words.fc.lzma", "rb") as fh:
    for line in fh:
        line = line.rstrip(b"\n")
        shared = line[0] - 0x40          # the first byte is the shared byte count, offset by 0x40
        prev = prev[:shared] + line[1:]  # keep the shared prefix, append the rest
        words.append(prev.decode("utf-8"))
print(len(words))  # 140011
```

**This snippet was run against the published file before it was published.** `python tools/verify-contribution.py`
fetches the objects from the bucket and checks that this reader rebuilds the plain list exactly — a reader that has
never been executed is a claim, not a reader.

`kn-words.txt` is the same list uncompressed, if a decoder is more trouble than 3.4 MB of bandwidth.

## Licence of these files

ODbL-1.0. See `NOTICE.md` and `LICENSE-ODbL-1.0.txt`.
