Emoji suggestions from Unicode CLDR keyword data
emojiunicodecldrkeyboardlicensingranking
Suggesting an emoji for a typed word ("pizza" to 🍕, "usa" to 🇺🇸) needs a word-to-emoji table. Matching the emoji's official Unicode name misses almost everything ("usa" is not in "flag: United States"); a hand list of 90 keywords covered 54 of the top 1,000 words. Building the table from Unicode CLDR took coverage of the top 10,000 English words from 325 to 1,363, and to about 4,750 words overall.
Sources and licenses
- Unicode CLDR (github.com/unicode-org/cldr, Unicode License v3):
annotationsandannotationsDerivedper locale (keywords and short names),main/<locale>.xmlterritory names (for flags),supplementalData.xmlalpha-3 codes. - CLDR release 45 vs 47: from release 46 the annotations added loose associations ("morning" to 💖, "father" to 🎅). Release 45 describes what the emoji shows. Use 45 for strip suggestions and 47 only for panel search.
- Unicode's emoji frequency ranking is a web page, not a data file under the Unicode License, so it was not used; a hand-made "most used first" list breaks ties instead.
- Credit sources in the README and the app's About screen.
Ranking rules that worked
- Claim strength: hand pick > named (emoji name, CLDR short name, country name, "X face" to X) > CLDR-45 keyword > CLDR-47 keyword (search only) > part of a name (search only).
- Common words get nothing unless hand-picked: words ranked under 300 need a hand pick; named claims need rank 300+; keywords need rank 1000+ and must not be shared by more than 8 emoji.
- Stop lists for words that would be noise; plurals inherit from their base; -ing/-ed forms only from an explicit verb list.
- Max 4 emoji per word; the most recently used among equally good choices wins (so 🐕 can beat 🐶 for "dog", but 🍕 never beats 🧀 for "cheese").
- Drop gendered ZWJ variants from the strip unless hand-picked.
Capitals and country codes
- "US", "UK", "EU", "UN" are offered only in capitals; lowercase "us", "in", "it", "no", "be", "is", "to", "me" never get flags. Lowercase "usa", "uk", "uae", "eu" do (they are not words).
- Alpha-3 codes ("MEX", "FRA") count only when the code is not a dictionary word.
- Autocorrect had been turning "usa " into "Us" and losing the flag; add explicit fixes "usa" to "USA".
- In Spanish, "usa" is a verb and gets nothing.
Words still being typed
Looking up only the exact typed letters means "bunn" gets no 🐰 even while "bunny" sits on the strip. Fix (v1.27): when the typed letters are not a word themselves and are at least 3 letters long, borrow the emoji of the first strip guess that is the correction or starts with the typed letters. A known word with no emoji never borrows ("bun", "the" stay empty). Tapping the borrowed emoji replaces the typed letters. Results: piz to 🍕, coff to ☕, helo to 👋, fra to 🇫🇷.
Storage
Keep the generated file as one string plus a line-start index and binary-search it: no per-entry objects, one language in memory, no measurable change in cold open time.
See also
- Keyboard autocorrect, next-word prediction and learning
- Writing an Android keyboard (InputMethodService)