Abbrev
Calculates the set of unambiguous abbreviations for a given set of strings.
This module is a straightforward port of Ruby's
Abbrev.
Constants
VERSION = "0.1.0"
Instance methods
abbrev(words : Enumerable(String), pattern : Regex | Nil = nil)
Generates a table of unambiguous abbreviations for each word in words.
If pattern is given, then only those abbreviations that match the pattern are included in the table.
Returns a Hash containing the mappings of abbreviations to words.
Abbrev.abbrev(%w{crystal})
# => {"crystal" => "crystal", "crysta" => "crystal", "cryst" => "crystal", "crys" => "crystal", "cry" => "crystal", "cr" => "crystal", "c" => "crystal"}
Abbrev.abbrev(%w{crystal ruby}, /^r/)
# => {"ruby" => "ruby", "rub" => "ruby", "ru" => "ruby", "r" => "ruby"}