Sha256: a8f5ab2093546fc0495c053c100496fa852632660ec0d2fbfade3296c1ea00e3
Contents?: true
Size: 526 Bytes
Versions: 69
Compression:
Stored size: 526 Bytes
Contents
defmodule ETL do @doc """ Transform an index into an inverted index. ## Examples iex> ETL.transform(%{"a" => ["ABILITY", "AARDVARK"], "b" => ["BALLAST", "BEAUTY"]]) %{"ability" => "a","aardvark" =>"a","ballast" =>"b","beauty" =>"b"] """ def transform(input) do input |> Map.to_list() |> invert |> List.flatten() |> Enum.into(%{}) end defp invert(pairs) do Enum.map(pairs, fn {key, values} -> Enum.map(values, fn value -> {String.downcase(value), key} end) end) end end
Version data entries
69 entries across 69 versions & 1 rubygems