word_info v0.1.0 WordInfo View Source

Get the pronunciation and frequency information of a word.

Syllables

iex> WordInfo.syllables("tradition")
["tra", "di", "tion"]

ARPABET pronunciation phonemes

iex> WordInfo.arpabet("halfway")
["HH", "AE1", "F", "W", "EY1"]

IPA pronunciation phonemes

iex> WordInfo.ipa("halfway")
["ˈhæfˈweɪ"]

Word frequency

iex> WordInfo.frequency("scientist")
5499

The number 5499 means it's ranked at 5499 on frequncy.

Acknowledgements

Here are the data sources of this library, without which this library is impossible.

Link to this section Summary

Functions

Fetch the pronunciation of a word from CMU dictionary, in ARPABET format

Fetch the frequency rating of a word.

Fetch the pronunciation of a word from CMU dictionary, with IPA pronu

Split the headword into syllables

Link to this section Functions

Link to this function

arpabet(word)

View Source
arpabet(binary()) :: [String.t()] | :unkown

Fetch the pronunciation of a word from CMU dictionary, in ARPABET format

See also: https://en.wikipedia.org/wiki/ARPABET

Returnss

  • :unknown if not found in the dictionary
  • A list of ARPABET phonemes.

Examples

iex> WordInfo.arpabet("world")
["W", "ER1", "L", "D"]

iex> WordInfo.arpabet("semi-colon")
["S", "EH1", "M", "IY0", "K", "OW1", "L", "AH0", "N"]
Link to this function

frequency(word)

View Source
frequency(binary()) :: :unkown | pos_integer()

Fetch the frequency rating of a word.

The rating is based on data from cmudict-ipa, which uses Brown Corpus of American English originally.

Returnss

  • :unknown if not found in the dictionary
  • an rating number, the smaller the frequenter. For instance, 1 is the most used word "THE".

Examples

iex> WordInfo.frequency("traditional")
1365

iex> WordInfo.frequency("some-unknown-word")
:unkown
Link to this function

ipa(word)

View Source
ipa(binary()) :: [String.t()] | :unknown

Fetch the pronunciation of a word from CMU dictionary, with IPA pronu

Returnss

  • :unknown if not found in the dictionary
  • A list of IPA pronunciations, all for the full word.

Examples

iex> WordInfo.ipa("world")
["ˈwɝːld"]

iex> WordInfo.ipa("semi-colon")
["ˈsɛmiːˈkoʊlən,", "ˈsɛməˈkoʊlən"]

iex> WordInfo.ipa("lalalal")
:unknown
Link to this function

syllables(word)

View Source
syllables(binary()) :: [String.t()] | :unknown

Split the headword into syllables

Returnss

  • :unknown if not found in the dictionary
  • A list of syllables.

Example

iex> WordInfo.syllables("edition")
["e", "di", "tion"]

iex> WordInfo.syllables("something-not-in-the-dictionary")
:unknown