Module: StringMetric::Levenshtein
- Defined in:
- lib/string_metric/levenshtein.rb,
lib/string_metric/levenshtein/recursive.rb,
lib/string_metric/levenshtein/trie_node.rb,
lib/string_metric/levenshtein/experiment.rb,
lib/string_metric/levenshtein/trie_radix_tree.rb,
lib/string_metric/levenshtein/trie_radix_tree_ext.rb,
lib/string_metric/levenshtein/iterative_with_full_matrix.rb,
lib/string_metric/levenshtein/iterative_with_two_matrix_rows.rb,
lib/string_metric/levenshtein/iterative_with_two_matrix_rows_ext.rb,
lib/string_metric/levenshtein/iterative_with_two_matrix_rows_optimized.rb,
ext/string_metric/levenshtein/trie_radix_tree/trie_radix_tree_ext.c,
ext/string_metric/levenshtein/iterative_with_two_matrix_rows/iterative_with_two_matrix_rows_ext.c
Overview
Levenshtein Distance implementation
Defined Under Namespace
Classes: Experiment, IterativeWithFullMatrix, IterativeWithTwoMatrixRows, IterativeWithTwoMatrixRowsExt, IterativeWithTwoMatrixRowsOptimized, Recursive, TrieNode, TrieRadixTree, TrieRadixTreeExt
Constant Summary collapse
- STRATEGIES =
{ experiment: Experiment, full_matrix: IterativeWithFullMatrix, recursive: Recursive, two_matrix_rows: IterativeWithTwoMatrixRows, two_matrix_rows_v2: IterativeWithTwoMatrixRowsOptimized }
Class Method Summary collapse
-
.default_strategy ⇒ Object
Currently the default strategy is set to IterativeWithTwoMatrixRows.
-
.distance(from, to, options = {}) ⇒ Fixnum, Float
Levenshtein Distance of two strings.
Class Method Details
.default_strategy ⇒ Object
Currently the default strategy is set to IterativeWithTwoMatrixRows
59 60 61 62 63 64 65 |
# File 'lib/string_metric/levenshtein.rb', line 59 def default_strategy if RUBY_ENGINE == "ruby" pick_strategy(:two_matrix_rows_ext) else pick_strategy(:two_matrix_rows) end end |
.distance(from, to, options = {}) ⇒ Fixnum, Float
Levenshtein Distance of two strings
50 51 52 53 54 55 |
# File 'lib/string_metric/levenshtein.rb', line 50 def distance(from, to, = {}) strategy = pick_strategy([:strategy]) || Levenshtein.default_strategy args = [from, to, ] strategy.distance(*args) end |