lib/phonetics/levenshtein.rb in phonetics-1.5.1 vs lib/phonetics/levenshtein.rb in phonetics-1.5.2

- old
+ new

@@ -1,5 +1,7 @@ +# frozen_string_literal: true + require_relative 'c_levenshtein' # Using the Damerau version of the Levenshtein algorithm, with phonetic feature # count used instead of a binary edit distance calculation # # This implementation is almost entirely taken from the damerau-levenshtein gem @@ -15,21 +17,21 @@ def self.distance(str1, str2) ensure_is_phonetic!(str1, str2) internal_phonetic_distance( Phonetics.as_utf_8_long(str1), - Phonetics.as_utf_8_long(str2), + Phonetics.as_utf_8_long(str2) ) end def self.ensure_is_phonetic!(str1, str2) [str1, str2].each do |string| string.chars.each do |char| unless Phonetics.phonemes.include?(char) - raise ArgumentError, "#{char.inspect} is not a character in the International Phonetic Alphabet. #{self.class.name} only works with IPA-transcribed strings" + msg = "#{char.inspect} is not a character in the International Phonetic Alphabet. #{self.class.name} only works with IPA-transcribed strings" + raise ArgumentError, msg end end end end - end end