Module: StringMetric::Levenshtein
- Defined in:
- lib/string_metric/levenshtein.rb,
lib/string_metric/levenshtein/recursive.rb,
lib/string_metric/levenshtein/experiment.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_optimized.rb
Overview
Levenshtein Distance implementation
Defined Under Namespace
Classes: Experiment, IterativeWithFullMatrix, IterativeWithTwoMatrixRows, IterativeWithTwoMatrixRowsOptimized, Recursive
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
51 52 53 54 55 56 57 |
# File 'lib/string_metric/levenshtein.rb', line 51 def default_strategy if RUBY_ENGINE == "ruby" pick_strategy(:two_matrix_rows_v2) else pick_strategy(:two_matrix_rows) end end |
.distance(from, to, options = {}) ⇒ Fixnum, Float
Levenshtein Distance of two strings
42 43 44 45 46 47 |
# File 'lib/string_metric/levenshtein.rb', line 42 def distance(from, to, = {}) strategy = pick_strategy([:strategy]) || Levenshtein.default_strategy args = [from, to, ] strategy.distance(*args) end |