- TypeScript 83.9%
- JavaScript 15.9%
- HTML 0.2%
| frontend | ||
| genesys-function | ||
| prompts | ||
| skills/dictionary-builder | ||
| .gitignore | ||
| README.md | ||
Dictionary AVA Tool
A dialect and language dictionary editor for text agents that only understand one language or dialect (e.g. UAE Arabic). An agent calls the deployed lookup function with the words or phrases it did not understand and gets their meanings back with a confidence score — so the meanings never have to sit in the agent's context.
browser (React + Vite + MUI) ── edits dictionary.json, tests searches
└─ builds ZIP in-browser ──► you upload it as a Genesys Cloud Function
agent ──► function {language, phrases[]} ──► matches + confidence scores
No server, no database, no embeddings. Everything runs on your machine in the browser; the dictionary lives in a JSON file you own.
Editor (frontend/)
cd frontend
npm install # also run once in ../genesys-function (the dev script does it for you)
npm run dev # http://localhost:5173
Workflow:
- Open a
dictionary.json(or create a new one). In Chromium browsers the file is saved back in place via the File System Access API; other browsers fall back to download/upload. - Define languages — a name (e.g. "Egyptian Arabic") and a slug used as the lookup
languagevalue and blob file name. - Define entries — word/phrase, its meaning, examples of use, and optional aliases (alternate spellings).
- Bulk import — paste CSV generated by an LLM (a markdown
```csvfence is stripped automatically, headerterm,meaning,aliases,examplein any order, aliases;-separated) or the quick manual pipe formatterm | meaning | alias1, alias2 | example, one per line, all-or-nothing validation. - Test lookup — runs the exact search code that ships in the bundle, with scores and match types.
- Build bundle — downloads
dictionary-function-<time>.zip, built entirely in the browser.
npm run build produces a static dist/ you can host anywhere. npm test runs the unit tests plus an end-to-end test that extracts the built ZIP and runs the real function handler on it.
dictionary.json
{
"schema": 1,
"languages": [
{
"name": "Egyptian Arabic",
"slug": "egyptian-arabic",
"description": "",
"entries": [
{ "term": "ازيك", "meaning": "how are you", "aliases": ["إزيك"], "examples": ["إزيك يا باشا"] }
]
}
]
}
How search works (and why these libraries)
Research summary (see the uFuzzy benchmark corpus of ~20 JS search libraries, 162k phrases):
- MiniSearch (6.2k★, zero dependencies, Node + browser) builds an in-memory inverted index with fuzzy and prefix matching and a fully customizable tokenizer — the only candidate that supports our Arabic normalisation. Kept for candidate generation.
- FlexSearch (fastest, but no true edit-distance fuzzy, ~316 MB retained heap), Fuse.js (O(n·m) scan, very slow at scale, poor default ranking), Lunr (unmaintained) and uFuzzy (fast, but Latin-optimised, no index, no calibrated score) were all rejected.
- fastest-levenshtein rescores each candidate into a calibrated 0..1 confidence. Raw BM25/TF-IDF scores are unbounded and meaningless as confidence, so scoring uses a match-type ladder instead.
Per phrase, in this order (all in-memory):
- exact — score 1.0 — after Arabic normalisation (diacritics, alef/ya/ta-marbuta variants, elongation
هلااااا) - elongation / exact_compact — 0.9 — doubled vowels; spacing variants
علطولvsعلى طول - contained — 0.83–0.92 — a dictionary term inside a longer phrase
- stem — 0.75 — Lucene-style light Arabic stemmer handles ال/بال/وال and possessive suffixes
- fuzzy — similarity² — Levenshtein-based spelling variants
Genesys Cloud Function (genesys-function/)
The function (index.handler) is deployed from the ZIP the editor builds. The ZIP layout is unchanged from the previous Python-built bundles: function sources, its node_modules, blobs/<language>.msgpack (MessagePack, format v3), manifest.json, dictionary.json for reference, plus input-schema.json / output-schema.json (JSON Schema draft-04 contracts for the Genesys Data Action — the validator rejects draft-07 — also shown with copy buttons on the Build bundle tab).
- Upload the ZIP (≤ 256 MB, unencrypted) in the Function tab. Handler
index.handler, Node.js runtime, 15 s timeout. - Input:
{ "language": "<slug>", "phrases": ["<phrase>", ...], "top_k"?: 1-10, "min_score"?: 0-1 }. Defaults:top_k3,min_score0.55. Max 100 phrases × 500 chars. The contract form is the array; the function also accepts a newline-separated string or a JSON-encoded array as text (curl convenience). - Output is a root object: summary scalars (
status,error_code,error_message,request_id,language,found,best_term,best_meaning,best_score,best_match_type) plus theresultsarray with full per-phrase detail (phrase,found,matches[]withterm,meaning,examples[],score,match_type,matched_key). - Blobs hold the entries verbatim; the function normalises, stems and indexes at cold start (~140 ms for 20k entries), and caches indexes across warm invocations.
- Tests:
cd genesys-function && npm install && npm test. Add real customer phrases totest/quality.test.jsto guard against regressions.
Example:
curl -d '{"language":"egyptian-arabic","phrases":["ازيك","عايز فلوس"]}' <function-url>
Generating dictionaries with an LLM (skills/ + prompts/)
The intended workflow: give an LLM your source documents plus the dictionary parameters, it returns a CSV, you paste it straight into the editor's bulk import. The loop is repeatable: the Export CSV button on a language's entries copies the current dictionary in the same format, so you can hand it plus new source material back to the LLM and import only the new entries.
skills/dictionary-builder/SKILL.md— a harness-agnostic skill file (standard frontmatter). Drop the folder into your agent's skills directory (Claude Code, opencode, etc.) and ask it to build a dictionary. It gathers the required inputs — language (required first), meaning language, source material, size, verbosity (brief / standard / verbose) — then emits the strict CSV contract the importer accepts.prompts/bulk-generation-prompt.md— the same contract as a raw prompt template for any chat LLM (placeholders:{{LANGUAGE}},{{MEANING_LANGUAGE}},{{SOURCE_MATERIAL}},{{COUNT}},{{VERBOSITY}}).
CSV contract: header term,meaning,aliases,example (order-insensitive,
auto-detected; without a header the canonical order is assumed), every field
double-quoted, aliases ;-separated in their cell, multiple examples
;-separated, one entry per line.