phonetics 1.5.4 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,14 +17,13 @@ module Phonetics
17
17
  attr_reader :str1, :str2, :len1, :len2, :matrix
18
18
 
19
19
  def initialize(ipa_str1, ipa_str2, verbose = false)
20
- @str1 = ipa_str1
21
- @str2 = ipa_str2
22
- @len1 = ipa_str1.size
23
- @len2 = ipa_str2.size
20
+ @str1 = ipa_str1.each_char.select { |c| Phonetics.phonemes.include?(c) }.join
21
+ @str2 = ipa_str2.each_char.select { |c| Phonetics.phonemes.include?(c) }.join
22
+ @len1 = @str1.size
23
+ @len2 = @str2.size
24
24
  @verbose = verbose
25
- ensure_is_phonetic!
26
25
  prepare_matrix
27
- set_edit_distances(ipa_str1, ipa_str2)
26
+ set_edit_distances(@str1, @str2)
28
27
  end
29
28
 
30
29
  def distance
@@ -40,14 +39,6 @@ module Phonetics
40
39
 
41
40
  private
42
41
 
43
- def ensure_is_phonetic!
44
- [str1, str2].each do |string|
45
- string.chars.each do |char|
46
- raise ArgumentError, "#{char.inspect} is not a character in the International Phonetic Alphabet. #{self.class.name} only works with IPA-transcribed strings" unless Phonetics.phonemes.include?(char)
47
- end
48
- end
49
- end
50
-
51
42
  def walk
52
43
  res = []
53
44
  i = len2
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phonetics
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Danger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-29 00:00:00.000000000 Z
11
+ date: 2019-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -115,11 +115,17 @@ files:
115
115
  - VERSION
116
116
  - _site/orthographic_example.png
117
117
  - _site/phonetic_example.png
118
+ - bin/console
118
119
  - ext/c_levenshtein/extconf.rb
119
120
  - ext/c_levenshtein/levenshtein.c
121
+ - ext/c_levenshtein/next_phoneme_length.c
122
+ - ext/c_levenshtein/next_phoneme_length.h
123
+ - ext/c_levenshtein/phonemes.c
124
+ - ext/c_levenshtein/phonemes.h
120
125
  - ext/c_levenshtein/phonetic_cost.c
121
126
  - ext/c_levenshtein/phonetic_cost.h
122
127
  - lib/phonetics.rb
128
+ - lib/phonetics/code_generator.rb
123
129
  - lib/phonetics/levenshtein.rb
124
130
  - lib/phonetics/ruby_levenshtein.rb
125
131
  - lib/phonetics/version.rb