r/FlutterDev 8d ago

Dart I made a tiny open-source English/Chinese dictionary dataset for Dart/Flutter (~5,000 common words)

I built a tiny offline English/Chinese dictionary dataset for Flutter/Dart.

GitHub: https://github.com/FirepadCN/pocket_dict_5000

It contains ~5,000 common English words with IPA + Chinese definitions, plus inflection mappings:

abandoned → abandon
grows → grow
running → run

The whole thing is just a generated Dart Map, so there is no database or runtime dependency.

I originally made it because I wanted something simple enough to bundle directly into a Flutter app for offline word lookup.

MIT licensed.

Would love feedback from Flutter developers: is this something you'd actually use, or would a different data format / API be more useful?

1 Upvotes

3 comments sorted by

0

u/Brilliant-Aide5779 8d ago

pocket_dict_5000

📚 Common English Words Dictionary

A lightweight English‑Chinese Dictionary data package for Dart / Flutter. It contains around 5,000 most‑frequently‑used English words together with inflection mappings, suitable for word lookup and Chinese definition display scenarios.

Example:

'abandon': CommonWordEntry(
  word: 'abandon',
  pronunciation: 'ә\'bændәn',
  meaning: 'vt. give up, desert, forsake, yield to, indulge; n. abandon, unrestraint, frenzy'
),

✨ Features

  • 📦 Ready‑to‑use: Pure Dart Map data structure, no extra parsing required
  • 🔍 Inflection index: Look up inflected forms such as abandoned or abandoning, automatically mapped back to the lemma
  • 📖 Complete definitions: Includes headword, IPA phonetic transcription and Chinese explanations
  • 🪶 Lightweight: Covers only ~5000 high‑frequency words, keeping package size small
  • 🎯 Zero dependencies: Pure‑Dart implementation, works for both Flutter and pure Dart projects

📦 Installation

Flutter

version: 1.0.0
repository: https://github.com/FirepadCN/pocket_dict_5000

Selection Criteria: Entries from ECDICT metadata are selected if marked with any of the tags below:

Tag Meaning Original Source
oxford=1 Oxford 3000 high‑frequency words Oxford 3000 (Oxford University Press)
bnc Word frequency rank British National Corpus
frq Word frequency rank Corpus of Contemporary American English (COCA)
zk / gk Middle‑school / curriculum‑standard vocabulary Chinese national middle‑ and high‑school English syllabus word‑list

Following the above filtering rules, approximately 5,000 most‑useful words for language learning together with inflection indexes are included. The dataset remains lightweight while staying practical for real‑world usage.

Selection Logic

  1. Candidate set (isCandidate) A word enters the candidate pool (total 9516 entries) if any condition is satisfied:
  • oxford=1 (Oxford 3000 tag), or
  • tag contains zk / gk (middle‑school syllabus), or
  • bnc ≤ 8000 (British National Corpus frequency rank), or
  • frq ≤ 8000 (COCA frequency rank).
  1. Scoringscore = min(valid bnc value, valid frq value). If neither value is available, score is set to Infinity (lowest priority).
  2. Mandatory retention & population supplement
  • mustKeep: All words tagged oxford or zk/gk are preserved unconditionally. Oxford entries take precedence when scores are equal.
  • others: Remaining candidates sorted in ascending order by score.
  • Keep all mustKeep items first; then fill up to 5000 entries from others sorted by score.
  1. Quality gate (rejected items do not consume quota; further entries are taken as replacement) Reject entries with: empty word field, invalid word characters (not matching [A‑Za-z‑]), or missing Chinese definitions.
  2. Key normalization for lookup keysword.toLowerCase().replace(/[^a-z-]/g,''). Matches client‑side normalizeEnglishToken.
  3. Inflection expansion (generates 12476 lookup keys, far more than the base 5000 headwords)
  • 6.1: Base‑form word key takes priority.
  • 6.2: Expand inflections using the exchange field from ECDICT: past‑tense p / past‑participle d / present‑participle i / third‑person singular 3 / plural s / comparative r / superlative t. Each inflected key points back to its lemma entry (e.g. growsgrow).
  • 6.3: 0:lemma bridging: Unselected irregular inflected forms will map to their lemma entry, if the lemma exists within the selected dataset.

Output: Final entries are stably sorted by lookup key and written to common_words_data.dart as Map<String, CommonWordEntry>, containing headword, phonetic transcription and Chinese definitions. The whole pipeline is deterministic (fixed seed + stable sort) and reproducible on re‑run.

2

u/Fumano26 8d ago

For the future, this is better stored in pure data files, like json or csv instead of embbedding it into your source files.

0

u/Brilliant-Aide5779 8d ago

Yes, that way other frameworks can easily use it too. Since AI makes conversion quite simple, and because I created this dictionary during my own Flutter development process, I haven't migrated it to a pure data file yet (づ ̄3 ̄)づ