# A Malayalam word pack, derived from Olam's Datuk corpus

**This folder is a derived database. It is licensed ODbL-1.0, like its source.** It comes from the **Datuk corpus**,
published by **Olam** — Kailash Nadh's Malayalam dictionary, maintained by the **Indic Digital Archive Foundation**. **The
words are theirs; only the shape is ours.**

| file | what it is | bytes |
| --- | --- | --- |
| `ml-words.txt` | **83,389 headwords**, one per line, NFC, LF | 2,000,332 |
| `ml-words.fc.lzma` | the same list, front-coded then lzma — **0.21 MB** | **217,024** |
| `ml-phones.tsv.lzma` | word to its first MLphone key | 445,352 |
| `ml-suffixes.tsv` | **73 endings** learned from the corpus, each with the counts that justify it | 1,185 |
| `manifest.json` | sizes and SHA-256 for everything above | — |

Rebuild with `python tools/malayalam-lexicon.py build`, then `python tools/malayalam-phonetics.py`, then
`python tools/malayalam-lexicon.py check` — the last one decodes the front-coded list and proves it matches the plain one.

## Where it comes from, exactly

- **Source:** `https://olam.in/files/datuk.tar.gz` — a TSV whose first column is the Malayalam headword
- **Licence:** ODbL-1.0, © the Datuk corpus as published by Olam
- **Attribution:** Kailash Nadh and Olam, Indic Digital Archive Foundation. `https://olam.in/p/open/datuk`

## Two things said plainly, because a pack that hides them is worse than no pack

1. **The phonetics are computed, not published by Olam.** They come from **MLphone**, the author's own phonetic algorithm
   (`github.com/knadh/mlphone`, no licence declared upstream). **The file is ready but its publication is pending his
   confirmation** — he is a correspondent of ours, and it is his algorithm. If he objects, one file is deleted.
2. **73 endings is a small number, and that is honest.** The Datuk headwords are mostly base forms, so there is little
   agglutination for the learner to find. The Kannada pack found 529 because Alar stores inflected forms beside their
   stems. **Do not read "73" as "Malayalam agglutinates less"** — it means this corpus does not show it.

## What it does not do yet

- **No coverage measurement.** The Kannada pack was tested against FLEURS `kn_in`. We hold no Malayalam speech test set
  in this workspace, so **there is no "34.2 % exact" number for Malayalam, and none is invented here.**
- **No guard yet.** The guard needs the suffix table, a function-word list and a sandhi rule. Only the first exists.

## Reading the front-coded list

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 counts **bytes**. Start with an empty previous word.

```python
import lzma

prev = b""
words = []
with lzma.open("ml-words.fc.lzma", "rb") as fh:
    for line in fh:
        shared = line[0] - 0x40
        prev = prev[:shared] + line[1:].rstrip(b"\n")
        words.append(prev.decode("utf-8"))
print(len(words))  # 83389
```
