lib/impl/words.ex

defmodule Dictionary.Impl.Words do
  @type t :: list(String)

  @spec word_list() :: t
  def word_list do
    "../../../../lib/word.txt"
    |> Path.expand(__DIR__)
    |> File.read!()
    |> String.split(~r{\n}, trim: true)
  end

  def generate_random(word_list) do
    word_list |> Enum.random()
  end
end