This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # String distance algorithms implementation | |
| class StringDistance | |
| # Calculates the Damerau-Levenshtein distance between two strings | |
| # This includes insertion, deletion, substitution, and transposition operations | |
| def self.damerau_levenshtein(str1, str2) | |
| # Input validation | |
| str1 = str1.to_s | |
| str2 = str2.to_s | |
| return str2.length if str1.empty? |
OlderNewer