Abbrev v0.1.0 Abbrev View Source
Calculates the set of unambiguous abbreviations for a given set of strings.
Link to this section Summary
Functions
Given a set of strings, calculate the set of unambiguous abbreviations for those strings, and return a map where the keys are all the possible abbreviations and the values are the full strings.
Given a set of strings and a pattern, calculate the set of unambiguous abbreviations for only those strings matching the pattern, and return a map where the keys are all the possible abbreviations and the values are the full strings.
Link to this section Functions
abbrev(words) View Source
Given a set of strings, calculate the set of unambiguous abbreviations for those strings, and return a map where the keys are all the possible abbreviations and the values are the full strings.
Parameters
- words - The set of strings from which to calculate the abbreviations.
Examples
iex> Abbrev.abbrev(~w())
%{}
iex> Abbrev.abbrev(~w(a))
%{"a" => "a"}
iex> Abbrev.abbrev(~w(a b))
%{"a" => "a", "b" => "b"}
iex> Abbrev.abbrev(~w(aa ab))
%{"aa" => "aa", "ab" => "ab"}
iex> Abbrev.abbrev(~w(car cone))
%{"ca" => "car", "car" => "car", "co" => "cone", "con" => "cone", "cone" => "cone"}
abbrev(words, pattern) View Source
Given a set of strings and a pattern, calculate the set of unambiguous abbreviations for only those strings matching the pattern, and return a map where the keys are all the possible abbreviations and the values are the full strings.
Parameters
- words - The set of strings from which to calculate the abbreviations.
- pattern - A regex or string; only input strings and abbreviations that match the pattern or string will be included in the return value.
Examples
iex> Abbrev.abbrev(~w(), ~r/^a/)
%{}
iex> Abbrev.abbrev(~w(a), ~r/^a/)
%{"a" => "a"}
iex> Abbrev.abbrev(~w(a b), ~r/^a/)
%{"a" => "a"}
iex> Abbrev.abbrev(~w(aa ab), ~r/b/)
%{"ab" => "ab"}
iex> Abbrev.abbrev(~w(car box cone crab), ~r/b/)
%{"b" => "box", "bo" => "box", "box" => "box", "crab" => "crab"}
iex> Abbrev.abbrev(~w(car box cone), "ca")
%{"ca" => "car", "car" => "car"}