random_words v1.1.0 RandomWords

Provide a random word from a list of 5,000 most common American English words. Provide options for multiple words at once and words of a particular part-of-speech.

Word list owned and provided by https://www.wordfrequency.info/. Their terms are that this list cannot be reproduced without crediting them by URL.

Link to this section Summary

Functions

Returns a word of type adjective. Note: this excludes determiners, numerals, and adjuncts. While technically part of the adjective family, they are specific cases. See wordlist/1 for any_adjective.

Returns a word of type adjunct

Returns a word of type adverb. Note: this excludes conjunctive_adverbs. While technically part of the adverb family, they are specific cases. See wordlist/1 for any_adverb.

Returns a word of type conjunctive_adverb

Returns a word of type determiner

Returns a word of type interjection

Returns a word of type noun

Returns a word of type numeral

Returns a word of type preposition

Returns a word of type pronoun

Returns a word of type verb

Examples

# Seed random generation for examples
iex> :rand.seed(:exs1024, {123, 123534, 345345})
iex> RandomWords.word()
"include"

Returns all the words available in any / the specified category.

Examples

# Seed random generation for examples
iex> :rand.seed(:exs1024, {123, 123534, 345345})
iex> RandomWords.words(3)
["gene", "peasant", "candidate"]

Link to this section Types

Specs

opts() :: [{:part_of_speech, part_of_speech_options()}]
Link to this type

part_of_speech()

Specs

part_of_speech() ::
  :adjective
  | :adjunct
  | :adverb
  | :conjunctive_adverb
  | :determiner
  | :interjection
  | :noun
  | :numeral
  | :preposition
  | :pronoun
  | :verb
Link to this type

part_of_speech_options()

Specs

part_of_speech_options() ::
  :any | :any_adverb | :any_adjective | part_of_speech()

Link to this section Functions

Specs

adjective() :: String.t()

Returns a word of type adjective. Note: this excludes determiners, numerals, and adjuncts. While technically part of the adjective family, they are specific cases. See wordlist/1 for any_adjective.

Specs

adjunct() :: String.t()

Returns a word of type adjunct

Specs

adverb() :: String.t()

Returns a word of type adverb. Note: this excludes conjunctive_adverbs. While technically part of the adverb family, they are specific cases. See wordlist/1 for any_adverb.

Link to this function

conjunctive_adverb()

Specs

conjunctive_adverb() :: String.t()

Returns a word of type conjunctive_adverb

Specs

determiner() :: String.t()

Returns a word of type determiner

Specs

interjection() :: String.t()

Returns a word of type interjection

Specs

noun() :: String.t()

Returns a word of type noun

Specs

numeral() :: String.t()

Returns a word of type numeral

Specs

preposition() :: String.t()

Returns a word of type preposition

Specs

pronoun() :: String.t()

Returns a word of type pronoun

Specs

verb() :: String.t()

Returns a word of type verb

Link to this function

word(opts \\ [part_of_speech: :any])

Specs

word(opts()) :: String.t()

Examples

# Seed random generation for examples
iex> :rand.seed(:exs1024, {123, 123534, 345345})
iex> RandomWords.word()
"include"
Link to this function

wordlist(opts \\ [part_of_speech: :any])

Specs

wordlist(opts()) :: [String.t()]

Returns all the words available in any / the specified category.

Note that the :any_adjective part-of-speech option includes the determiners, numerals, and adjuncts that are part of the broader adjective family.

Note that the :any_adverb part-of-speech option includes the conjunctive adverbs that are part of the broader adverb family.

Examples

iex> RandomWords.wordlist() |> length()
4995
iex> RandomWords.wordlist(part_of_speech: :verb) |> length()
1001
Link to this function

words(count, opts \\ [part_of_speech: :any])

Specs

words(non_neg_integer(), opts()) :: [String.t()]

Examples

# Seed random generation for examples
iex> :rand.seed(:exs1024, {123, 123534, 345345})
iex> RandomWords.words(3)
["gene", "peasant", "candidate"]