Sha256: 566f95cb9eb8b388591d9b0c1325b287e98dc4681ccca3c0323a31a24afc94e6

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require_relative '../phonetics'
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 was dually inspired by the damerau-levenshtein gem
# (https://github.com/GlobalNamesArchitecture/damerau-levenshtein/tree/master/ext/damerau_levenshtein).
# and "Using Phonologically Weighted Levenshtein Distances for the Prediction
# of Microscopic Intelligibility" by Lionel Fontan, Isabelle Ferrané, Jérôme
# Farinas, Julien Pinquier, Xavier Aumont, 2016
# https://hal.archives-ouvertes.fr/hal-01474904/document
module Phonetics
  module Levenshtein
    extend ::PhoneticsLevenshteinCBinding

    def inspect_bytes(str)
      puts "Rubyland str: #{str.inspect}"
      puts "Rubyland bytes: #{str.bytes.inspect}"
      testing_codepoints(str)
    end

    def self.distance(str1, str2, verbose = false)
      internal_phonetic_distance(str1, str2, verbose)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
phonetics-2.0.1 lib/phonetics/levenshtein.rb
phonetics-1.9.0 lib/phonetics/levenshtein.rb
phonetics-1.8.0 lib/phonetics/levenshtein.rb