# `Unicode.String.Dictionary`
[🔗](https://github.com/elixir-unicode/unicode_string/blob/v2.4.1/lib/unicode/dictionary.ex#L1)

Implements basic dictionary functions for dictionary-based
work break.

This implementation supports dictionary-based word breaking for:

* Chinese (`zh`, `zh-Hant`, `zh-Hans`, `zh-Hant-HK`, `yue`, `yue-Hans`) locales,
* Japanese (`ja`) using the same dictionary as for Chinese,
* Thai (`th`),
* Lao (`lo`),
* Khmer (`km`) and
* Burmese (`my`).

The dictionaries implemented are those used in the [CLDR](https://cldr.unicode.org) since
they are under an open source license and also for consistency with
[ICU](https://icu.unicode.org).

A dictionary is applied only to runs of text written in the script(s) it covers -
Han, Hiragana and Katakana for Chinese and Japanese, and the corresponding script
for Thai, Lao, Khmer and Burmese. Text in any other script, such as Latin words or
digits embedded in Japanese text, is broken by the standard
[Unicode Segmentation](https://unicode.org/reports/tr29/) rules.

Note that these dictionaries need to be downloaded with
`mix unicode.string.download.dictionaries` prior to use. Each dictionary
will be parsed and loaded into [persistent_term](https://www.erlang.org/doc/man/persistent_term)
on demand. Note that each dictionary has a sizable memory footprint as measured
by `:persistent_term.info/0`:

| Dictionary  | Memory Mb   |
| ----------- | ----------: |
| Chinese     | 104.8       |
| Thai        | 9.6         |
| Lao         | 11.4        |
| Khmer       | 38.8        |
| Burmese     | 23.1        |

# `known_dictionary_locales`

Returns the locales that have a dictionary supporting word breaking.

These are the locales whose scripts do not mark word boundaries with spaces,
so segmenting them requires a dictionary rather than the UAX #29 rules alone.

### Returns

* A list of locale atoms.

### Examples

    iex> locales = Unicode.String.Dictionary.known_dictionary_locales()
    iex> :th in locales and :ja in locales
    true

---

*Consult [api-reference.md](api-reference.md) for complete listing*
