ridic 0.6.4 → 0.6.5
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.
- data/lib/ridic/version.rb +1 -1
- data/lib/ridic.rb +23 -28
- metadata +2 -2
data/lib/ridic/version.rb
CHANGED
data/lib/ridic.rb
CHANGED
@@ -3,10 +3,13 @@ require "ridic/dictionary"
|
|
3
3
|
require 'benchmark'
|
4
4
|
|
5
5
|
module RiDic
|
6
|
+
@word_dictionary = RiDic::Dictionary.words
|
7
|
+
@stem_dictionary = RiDic::Dictionary.word_stems
|
8
|
+
|
6
9
|
def self.word_match(text_word)
|
7
10
|
text_word.upcase!
|
8
|
-
dictionary_1 =
|
9
|
-
dictionary_1 == nil ?
|
11
|
+
dictionary_1 = @word_dictionary[text_word]
|
12
|
+
dictionary_1 == nil ? @stem_dictionary[text_word] : dictionary_1
|
10
13
|
end
|
11
14
|
|
12
15
|
def self.stem_match(text_word)
|
@@ -17,7 +20,7 @@ module RiDic
|
|
17
20
|
|
18
21
|
max_length.downto(3) do |i|
|
19
22
|
text_word = text_word[0...i]
|
20
|
-
dictionary_2 =
|
23
|
+
dictionary_2 = @stem_dictionary[text_word]
|
21
24
|
(return dictionary_2) if dictionary_2 != nil
|
22
25
|
end
|
23
26
|
nil
|
@@ -60,31 +63,23 @@ module RiDic
|
|
60
63
|
document_text.split(' ').each {|word| word.gsub!(/\W/, '')}.join(' ')
|
61
64
|
end
|
62
65
|
|
63
|
-
# Benchmarking
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
# x.report('standard case no match orig_stem_match') do
|
81
|
-
# 100.times { RiDic.orig_stem_match("monkey") }
|
82
|
-
# end
|
83
|
-
# x.report('standard case no match new stem_match') do
|
84
|
-
# 100.times { RiDic.stem_match("monkey") }
|
85
|
-
# end
|
86
|
-
|
87
|
-
# end
|
66
|
+
# Benchmarking (disabled by default)
|
67
|
+
|
68
|
+
Benchmark.bmbm do |x|
|
69
|
+
|
70
|
+
x.report('edge case stem_match') do
|
71
|
+
100.times { RiDic.stem_match("playingtasticallymajorpainisticyodudehahaha") }
|
72
|
+
end
|
73
|
+
|
74
|
+
x.report('standard case stem_match') do
|
75
|
+
100.times { RiDic.stem_match("playing") }
|
76
|
+
end
|
77
|
+
|
78
|
+
x.report('standard case no match stem_match') do
|
79
|
+
100.times { RiDic.stem_match("monkey") }
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
88
83
|
|
89
84
|
end
|
90
85
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ridic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-01-
|
12
|
+
date: 2013-01-19 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Ruby gem wrapper for the Regressive Imagery Dictionary
|
15
15
|
email:
|