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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c4c2bca09dd68c9a2dd10417d4c05ba788913a93cdead88151b47908249aca6
4
- data.tar.gz: c131c5aa7695f12a79253a60fecdf6c2b0a2ab140e48dcca098d5c9b1dd3a928
3
+ metadata.gz: b763cbe40f7ad1a595780ae6432bb152e3d65ba630e59e95e2a50f2e4c91d331
4
+ data.tar.gz: f7b13ec8d7f01a7be74b086320402c8bce4212f8f98e1afaf139fa393cf8a287
5
5
  SHA512:
6
- metadata.gz: e6596b4e79216fe04dcd5eb34a9e33a5782ec7b66759f551cb82ced8a9cfc9dc73d708a430b92e6c3911659a4c1214db4a984402bba7059443e95143e1b7d64e
7
- data.tar.gz: d41b961adf80133566ec00f83bfa17d8e5b3b83c28afe6bbfb22d1f3bb71101d352c3060c774a81d5ee6ee9ce59779a57c2aa874951df48233522e423f1850ef
6
+ metadata.gz: 2a219c6d0e9529dbba64b2afa6551a288f84289d54bda3352bbd9f936498fea7b682fddee5c6560282e18df9c4da0f8763638ad5644a544994f53c69383cd19f
7
+ data.tar.gz: fec4853f5b3db302e8c4da92ecf16b32d01bd5916cced019ec74fe7717021d0dd68a7118d2310288325164f7c3fa196370f4acd32912c5a39872b7041734ce0e
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- d2w (0.1.0)
4
+ d2w (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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 path_of_dictionar
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","/Users/babaloo/Downloads/dictionary.txt")}
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","/Users/babaloo/Downloads/dictionary.txt")}
50
+ Benchmark.measure{D2W::PhoneToWord.new.digit2word("6686787825")}
52
51
 
53
52
  Got Details
54
53
 
@@ -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
- dict.each do |word|
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
@@ -1,3 +1,3 @@
1
1
  module D2w
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
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.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-18 00:00:00.000000000 Z
11
+ date: 2019-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor