View Source Trivium
Library to generate 3 unique 3 word phrases, probably to use as slugs.
Also known as: "Ridiculously Handsome Teenager"
Usage
Add this to your config.exs file
:trivium,
format: %{order: [:adjectives, :adverbs, :nouns]},
sources: %{adjectives: "src/adjectives.exs", adverbs: "src/adverbs.exs", nouns: "src/nouns.exs"}
And start the Dictionary genserver in your application.ex file
def start(_, _) do
Trivium.Dictionary,
...
end
Then, generate a new slug using:
Trivium.generate()
Or, use the Mix Task:
mix slug.generate
Caveats
This library makes no guarantee of uniqueness. Although the chances of a collison are exceedingly low, they are not zero. If you need to guarantee uniqueness, add an external validator (such as a Bloom filter or RDBMS unique column.)
Installation
If available in Hex, the package can be installed
by adding trivium
to your list of dependencies in mix.exs
:
def deps do
[
{:trivium, "~> 0.1.0"}
]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/trivium.
TODO
Add telemetry that reports a hash of the generated phrase
- collect the data to display on a website, showing how many have been generated and how many collisions