jebediah 1.0.5 → 1.0.6
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/lib/jebediah.rb +6 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e5683dce55e78114f7648d1fe1fd30b39225c13
|
4
|
+
data.tar.gz: d4e550b81a724f2d71e650dfa92adc6326a3e21b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a2a2e47295f0163acbdf2f68e99b2c1c90dd3a7c5c01ce28d49facc08de677cf1286efa904bdc7a6187edd672a66946548534ea46a22778c3223347d556cc84
|
7
|
+
data.tar.gz: 5e4f98120bc4a6e785b4b43033c9275d9a324f09373f7e32eb1fe2ae781970694a5f6a2f95a7bff794b364e221353a7bf9005aae43f4266b43cbf240375a885a
|
data/lib/jebediah.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Jebediah
|
2
2
|
def self.version
|
3
|
-
return "1.0.
|
3
|
+
return "1.0.6"
|
4
4
|
end
|
5
5
|
|
6
6
|
def initialize(dictPaths=nil)
|
@@ -159,7 +159,9 @@ class Jebediah
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def longestMatchInDictionary(words, dict)
|
162
|
-
words.count.times.map { |n| words[0..n].join("-") }
|
162
|
+
hyphenated = words.count.times.map { |n| words[0..n].join("-") }
|
163
|
+
in_dictionary = hyphenated.select { |phrase| dict.include?(phrase) }
|
164
|
+
in_dictionary.last.split("-") rescue nil
|
163
165
|
end
|
164
166
|
|
165
167
|
def dehyphenatePhrase(phrase)
|
@@ -168,6 +170,8 @@ class Jebediah
|
|
168
170
|
@dictionaries.each do |dict|
|
169
171
|
return nil if phrase.empty?
|
170
172
|
match = longestMatchInDictionary(phrase, dict)
|
173
|
+
return nil if match.nil?
|
174
|
+
|
171
175
|
split << match.join("-")
|
172
176
|
phrase = phrase[match.count .. -1]
|
173
177
|
end
|