soundex 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/soundex.rb +22 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d782c368e8ff54e4a0a43510216951d0182d6232
|
4
|
+
data.tar.gz: e5b882e0ff5c0b97129a50afbbbda8cdfe4d0e4c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4364ff732dccb1215b629e40cab372b9cf64bde305f1402dc6dbf31109139f2b79913b1e394e49f6ee01b4123457e0e0968171714cf70650207f9eaac989b421
|
7
|
+
data.tar.gz: af976202f3b3c2336e0677c8e9746d74e2e8acf2a25b416b73a59595b348b98bc0311a3c4565e0319c48c57e3eeb3b6abd1df3230bf2b823754468de2def89e1
|
data/lib/soundex.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
def soundex word
|
2
|
+
text = word
|
3
|
+
soundex = ""
|
4
|
+
loop do
|
5
|
+
text = text.downcase
|
6
|
+
first_letter = text[0]
|
7
|
+
other_letters = text[1..text.length]
|
8
|
+
other_letters = other_letters.gsub /[aeiouyhw]/, ''
|
9
|
+
other_letters = other_letters.gsub /[bfpv]/, '1'
|
10
|
+
other_letters = other_letters.gsub /[cgjkqsxz]/, '2'
|
11
|
+
other_letters = other_letters.gsub /[dt]/, '3'
|
12
|
+
other_letters = other_letters.gsub /[i]/, '4'
|
13
|
+
other_letters = other_letters.gsub /[mn]/, '5'
|
14
|
+
other_letters = other_letters.gsub /r/, '6'
|
15
|
+
(1..6).to_a.each do |num|
|
16
|
+
other_letters = other_letters.gsub Regexp.new("#{num}+"), num.to_s
|
17
|
+
end
|
18
|
+
text = first_letter + other_letters
|
19
|
+
break if text.match /\w\d+/
|
20
|
+
end
|
21
|
+
(text + "0000")[0..3]
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: soundex
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Karthikeyan A K
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-08-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Get American soundex of an word
|
14
|
+
email: 77minds@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/soundex.rb
|
20
|
+
homepage: https://github.com/mindaslab/soundex
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.2.2
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Get American soundex of an word
|
44
|
+
test_files: []
|