d2w 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -4
- data/lib/d2w/phone_to_word.rb +4 -24
- data/lib/d2w/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b763cbe40f7ad1a595780ae6432bb152e3d65ba630e59e95e2a50f2e4c91d331
|
4
|
+
data.tar.gz: f7b13ec8d7f01a7be74b086320402c8bce4212f8f98e1afaf139fa393cf8a287
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a219c6d0e9529dbba64b2afa6551a288f84289d54bda3352bbd9f936498fea7b682fddee5c6560282e18df9c4da0f8763638ad5644a544994f53c69383cd19f
|
7
|
+
data.tar.gz: fec4853f5b3db302e8c4da92ecf16b32d01bd5916cced019ec74fe7717021d0dd68a7118d2310288325164f7c3fa196370f4acd32912c5a39872b7041734ce0e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -24,9 +24,8 @@ Or install it yourself as:
|
|
24
24
|
clone the gem into your local machin and go to that folder
|
25
25
|
on terminal run the following command with mobile_number
|
26
26
|
|
27
|
-
path_of_dictionar = "/Users/babaloo/Downloads/dictionary.txt" (Example path)
|
28
27
|
|
29
|
-
d2w translate 2282668687
|
28
|
+
d2w translate 2282668687
|
30
29
|
|
31
30
|
2282668687 is phone no.
|
32
31
|
|
@@ -41,14 +40,14 @@ Output for 6686787825
|
|
41
40
|
## Benchmark
|
42
41
|
Runnig Benchmark for phone_no 2282668687
|
43
42
|
|
44
|
-
Benchmark.measure{D2W::PhoneToWord.new.digit2word("2282668687"
|
43
|
+
Benchmark.measure{D2W::PhoneToWord.new.digit2word("2282668687")}
|
45
44
|
Got Details
|
46
45
|
|
47
46
|
#<Benchmark::Tms:0x00007f8051c38538 @label="", @real=1.1990008849970764, @cstime=0.0, @cutime=0.0, @stime=0.010602, @utime=1.172868, @total=1.18347>
|
48
47
|
|
49
48
|
Runnig Benchmark for phone_no 2282668687
|
50
49
|
|
51
|
-
Benchmark.measure{D2W::PhoneToWord.new.digit2word("6686787825"
|
50
|
+
Benchmark.measure{D2W::PhoneToWord.new.digit2word("6686787825")}
|
52
51
|
|
53
52
|
Got Details
|
54
53
|
|
data/lib/d2w/phone_to_word.rb
CHANGED
@@ -2,32 +2,14 @@ module D2W
|
|
2
2
|
# require 'thor'
|
3
3
|
class PhoneToWord
|
4
4
|
def digit2word(phone_no)
|
5
|
-
|
6
5
|
# path_of_dictionary = "/Users/babaloo/Downloads/dictionary.txt"
|
7
|
-
|
8
|
-
if phone_no.nil? || phone_no.length != 10 || phone_no.split('').select{|a|(a.to_i == 0 || a.to_i == 1)}.length > 0
|
9
|
-
return []
|
10
|
-
end
|
11
|
-
dw_map = {
|
12
|
-
"2" => ["a", "b", "c"],
|
13
|
-
"3" => ["d", "e", "f"],
|
14
|
-
"4" => ["g", "h", "i"],
|
15
|
-
"5" => ["j", "k", "l"],
|
16
|
-
"6" => ["m", "n", "o"],
|
17
|
-
"7" => ["p", "q", "r", "s"],
|
18
|
-
"8" => ["t", "u", "v"],
|
19
|
-
"9" => ["w", "x", "y", "z"]
|
20
|
-
}
|
21
|
-
|
6
|
+
dw_map = { "2" => ["a", "b", "c"],"3" => ["d", "e", "f"],"4" => ["g", "h", "i"], "5" => ["j", "k", "l"], "6" => ["m", "n", "o"], "7" => ["p", "q", "r", "s"],"8" => ["t", "u", "v"], "9" => ["w", "x", "y", "z"]}
|
22
7
|
#this is path of given dictionary in my local machine
|
23
|
-
dict = D2W::Dictionary.new.dictionary
|
24
|
-
|
25
|
-
#fetching dictionay in my local dictionary array with leght 3,5,7,4,6,10
|
26
|
-
dict = dict.map(&:downcase)
|
27
8
|
dictionary = []
|
28
|
-
|
9
|
+
D2W::Dictionary.new.dictionary.map(&:downcase).each do |word|
|
29
10
|
dictionary << word if [3,4,5,6,7,10].include?(word.length)
|
30
11
|
end
|
12
|
+
|
31
13
|
# get all letters for numbers in form of array
|
32
14
|
|
33
15
|
keys = phone_no.split('').map{|digit| dw_map[digit]}.flatten
|
@@ -37,9 +19,7 @@ module D2W
|
|
37
19
|
# filter words which is possible for given phone number
|
38
20
|
|
39
21
|
dictionary.each do |word|
|
40
|
-
if (word.split("") - keys).empty?
|
41
|
-
possible_words << word
|
42
|
-
end
|
22
|
+
possible_words << word if (word.split("") - keys).empty?
|
43
23
|
end
|
44
24
|
exact_words = []
|
45
25
|
# filer exact words for phone number from possible words
|
data/lib/d2w/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: d2w
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- BabalooPatel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|