phonetics 3.0.6 → 3.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/ext/c_levenshtein/phonetic_cost.c +11858 -11858
- data/lib/phonetics/distances.rb +5 -5
- metadata +1 -1
data/lib/phonetics/distances.rb
CHANGED
@@ -183,20 +183,20 @@ module Phonetics
|
|
183
183
|
|
184
184
|
# Given two consonants, calculate their difference by summing the
|
185
185
|
# following:
|
186
|
-
# * 0.
|
186
|
+
# * 0.3 if they are not voiced the same
|
187
187
|
# * 0.3 if they are different manners
|
188
|
-
# * Up to 0.
|
188
|
+
# * Up to 0.4 if they are the maximum position difference
|
189
189
|
def distance(phoneme1, phoneme2)
|
190
190
|
features1 = features[phoneme1]
|
191
191
|
features2 = features[phoneme2]
|
192
192
|
|
193
193
|
penalty = 0
|
194
|
-
penalty += 0.
|
194
|
+
penalty += 0.3 if features1[:voiced] != features2[:voiced]
|
195
195
|
|
196
196
|
penalty += 0.3 if features1[:manner] != features2[:manner]
|
197
197
|
|
198
|
-
# Use up to the remaining 0.
|
199
|
-
penalty += 0.
|
198
|
+
# Use up to the remaining 0.4 for penalizing differences in manner
|
199
|
+
penalty += 0.4 * ((features1[:position_index] - features2[:position_index]).abs / @position_count.to_f)
|
200
200
|
penalty
|
201
201
|
end
|
202
202
|
end
|