moby 1.0.1beta

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,271 @@
1
+ require 'spec_helper'
2
+ require 'yaml'
3
+
4
+ module Moby
5
+ describe PartsOfSpeech do
6
+ let(:pos) { PartsOfSpeech.new }
7
+
8
+ describe "#find" do
9
+ describe "all words" do
10
+ let(:word) { "purple" }
11
+ subject { pos.find(word) }
12
+ its([:word]) { should == word }
13
+ end
14
+
15
+ describe "unlisted word" do
16
+ let(:word) { "_unlisted" }
17
+ subject { pos.find(word) }
18
+ its([:found]) { should be_false }
19
+ end
20
+
21
+ describe "listed word" do
22
+ let(:word) { "noise limiter" }
23
+ subject { pos.find(word) }
24
+ its([:found]) { should be_true }
25
+ end
26
+
27
+ describe "_unlisted" do
28
+ let(:word) { "_unlisted" }
29
+ subject { pos.find(word) }
30
+ its([:word]) { should == word }
31
+ its([:found]) { should be_false }
32
+ its([:code]) { should == "" }
33
+ its([:pos]) { should == [] }
34
+ end
35
+
36
+ describe "specific words" do
37
+ describe "rabbling" do
38
+ subject { pos.find("rabbling") }
39
+ its([:code]) { should == "Vti" }
40
+ its([:pos]) {
41
+ should == [:verb_usu_participle, :verb_transitive, :verb_intransitive]
42
+ }
43
+ end
44
+
45
+ describe "saccharine" do
46
+ subject { pos.find("saccharine") }
47
+ its([:code]) { should == "A" }
48
+ its([:pos]) { should == [:adjective] }
49
+ end
50
+
51
+ describe "tailgate" do
52
+ subject { pos.find("tailgate") }
53
+ its([:code]) { should == "NV" }
54
+ its([:pos]) { should == [:noun, :verb_usu_participle] }
55
+ end
56
+
57
+ describe "ulcerously" do
58
+ subject { pos.find("ulcerously") }
59
+ its([:code]) { should == "v" }
60
+ its([:pos]) { should == [:adverb] }
61
+ end
62
+ end
63
+ end
64
+
65
+ describe "wordlist by part of speech" do
66
+ describe "#nouns" do
67
+ subject { pos.nouns }
68
+ it { should include("abaca", "unchildishness", "transcription" ) }
69
+ end
70
+
71
+ describe "#plurals" do
72
+ subject { pos.plurals }
73
+ it { should include("transennae", "uranalyses", "waterfowls" ) }
74
+ end
75
+
76
+ describe "#noun_phrases" do
77
+ subject { pos.noun_phrases }
78
+ it { should include(
79
+ "waxed paper", "Joan of Arc", "absence of mind"
80
+ )}
81
+ end
82
+
83
+ describe "#verbs" do
84
+ describe ":type => all or :type not given" do
85
+ subject { pos.verbs }
86
+ it { should include(*%w{jobbed outproducing about-shipping}) }
87
+ end
88
+
89
+ describe ":type => :usu" do
90
+ subject { pos.verbs(:type => :usu) }
91
+ it { should include("jobbed", "lattice", "minify" ) }
92
+ end
93
+
94
+ describe ":type => :transitive" do
95
+ subject { pos.verbs(:type => :transitive) }
96
+ it { should include("misgauged", "outproducing", "parade" ) }
97
+ end
98
+
99
+ describe ":type => :intransitive" do
100
+ subject { pos.verbs(:type => :intransitive) }
101
+ it { should include("paralogized", "skreegh", "about-shipping" ) }
102
+ end
103
+ end
104
+
105
+ describe "#adjectives" do
106
+ subject { pos.adjectives }
107
+ it { should include("about", "garrulous", "hesperideous" ) }
108
+ end
109
+
110
+ describe "#adverbs" do
111
+ subject { pos.adverbs }
112
+ it { should include("heterodoxly", "nondiabolically", "stoutly" ) }
113
+ end
114
+
115
+ describe "#conjunctions" do
116
+ subject { pos.conjunctions }
117
+ it { should include("syne", "lest", "notwithstanding" ) }
118
+ end
119
+
120
+ describe "#prepositions" do
121
+ subject { pos.prepositions }
122
+ it { should include("off", "senza", "except" ) }
123
+ end
124
+
125
+ describe "#interjections" do
126
+ subject { pos.interjections }
127
+ it { should include("eyes front", "horsefeathers", "jeepers" ) }
128
+ end
129
+
130
+ describe "#pronouns" do
131
+ subject { pos.pronouns }
132
+ it { should include("lot", "me", "noblewoman" ) }
133
+ end
134
+
135
+ describe "#definite_articles" do
136
+ subject { pos.definite_articles }
137
+ it { should include("no", "other", "per" ) }
138
+ end
139
+
140
+ describe "#indefinite_articles" do
141
+ pending("No definite articles in current Moby POS")
142
+ end
143
+
144
+ describe "#nominatives" do
145
+ pending("No nominatives in current Moby POS")
146
+ end
147
+ end
148
+
149
+ describe "query methods" do
150
+ describe "#noun?" do
151
+ %w{gait teaspoon decorum}.each do |word|
152
+ subject { pos.noun?(word) }
153
+ describe(word) { it { should be_true } }
154
+ end
155
+ end
156
+
157
+ describe "#plural?" do
158
+ %w{waterleafs xoanona argosies}.each do |word|
159
+ subject { pos.plural?(word) }
160
+ describe(word) { it { should be_true } }
161
+ end
162
+ end
163
+
164
+ describe "#noun_phrase?" do
165
+ ["argon potassium dating",
166
+ "nonharmonic tone",
167
+ "nook shaft"].each do |word|
168
+ subject { pos.noun_phrase?(word) }
169
+ describe(word) { it { should be_true } }
170
+ end
171
+ end
172
+
173
+ describe "#adjective?" do
174
+ %w{nonzonated oliguretic conservable}.each do |word|
175
+ subject { pos.adjective?(word) }
176
+ describe(word) { it { should be_true } }
177
+ end
178
+ end
179
+
180
+ describe "#adverb?" do
181
+ %w{evaporatively hyperactively lonesomely}.each do |word|
182
+ subject { pos.adverb?(word) }
183
+ describe(word) { it { should be_true } }
184
+ end
185
+ end
186
+
187
+ describe "#conjunction?" do
188
+ %w{moreover saving opuscule}.each do |word|
189
+ subject { pos.conjunction?(word) }
190
+ describe(word) { it { should be_true } }
191
+ end
192
+ end
193
+
194
+ describe "#preposition?" do
195
+ %w{of outside between}.each do |word|
196
+ subject { pos.preposition?(word) }
197
+ describe(word) { it { should be_true } }
198
+ end
199
+ end
200
+
201
+ describe "#interjection?" do
202
+ %w{bingo halt viva}.each do |word|
203
+ subject { pos.interjection?(word) }
204
+ describe(word) { it { should be_true } }
205
+ end
206
+ end
207
+
208
+ describe "#pronoun?" do
209
+ %w{nobody hisself whereinto}.each do |word|
210
+ subject { pos.pronoun?(word) }
211
+ describe(word) { it { should be_true } }
212
+ end
213
+ end
214
+
215
+ describe "#definite_article?" do
216
+ %w{no more enough}.each do |word|
217
+ subject { pos.definite_article?(word) }
218
+ describe(word) { it { should be_true } }
219
+ end
220
+ end
221
+
222
+ describe "#indefinite_aticle?" do
223
+ pending("No definite articles in current Moby POS")
224
+ end
225
+
226
+ describe "#nominative?" do
227
+ pending("No nominatives in current Moby POS")
228
+ end
229
+
230
+ describe "#verb?" do
231
+ describe ":type => :all or :type not given" do
232
+ %w{dwelled hypostasize pose}.each do |word|
233
+ describe word do
234
+ subject { pos.verb?(word, :type => :all) }
235
+ it { should be_true }
236
+ end
237
+ end
238
+ end
239
+
240
+ describe ":type => :usu" do
241
+ %w{regrinding shimmy resalute}.each do |word|
242
+ describe word do
243
+ subject { pos.verb?(word, :type => :all) }
244
+ it { should be_true }
245
+ end
246
+ end
247
+ end
248
+
249
+ describe ":type => :transitive" do
250
+ %w{resampled agitate eternalizing}.each do |word|
251
+ describe word do
252
+ subject { pos.verb?(word, :type => :all) }
253
+ it { should be_true }
254
+ end
255
+ end
256
+ end
257
+
258
+ describe ":type => :intransitive" do
259
+ %w{joy-ridden superaccruing bing}.each do |word|
260
+ describe word do
261
+ subject { pos.verb?(word, :type => :all) }
262
+ it { should be_true }
263
+ end
264
+ end
265
+ end
266
+
267
+ end
268
+ end
269
+
270
+ end
271
+ end
data/spec/moby_spec.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe Moby do
4
+ describe "::VERSION" do
5
+ it "should be a valid SemVer string" do
6
+ Moby::VERSION.should match(/^(\d+\.){2}\d+([a-z](\w+)?)?$/)
7
+ end
8
+ end
9
+
10
+ describe "::base_path" do
11
+ it "should return the absolute root path of the application" do
12
+ Moby::base_path.should == File.expand_path("../..", __FILE__)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ require 'moby'
2
+
3
+ RSpec.configure do |cfg|
4
+ cfg.color_enabled = true
5
+ cfg.formatter = "documentation"
6
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: moby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1beta
5
+ prerelease: 5
6
+ platform: ruby
7
+ authors:
8
+ - Dan Richert
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-01 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &7748020 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *7748020
25
+ description: Ruby interface for the world's largest free phonetic database
26
+ email:
27
+ - dan.richert@gmail.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - .rvmrc
34
+ - Gemfile
35
+ - Gemfile.lock
36
+ - README.md
37
+ - Rakefile
38
+ - lib/moby.rb
39
+ - lib/moby/parts_of_speech.rb
40
+ - lib/moby/version.rb
41
+ - moby.gemspec
42
+ - share/moby/parts-of-speech/aaREADME.txt
43
+ - share/moby/parts-of-speech/mobypos.UTF-8.txt
44
+ - share/moby/parts-of-speech/mobypos.txt
45
+ - spec/moby/parts_of_speech_spec.rb
46
+ - spec/moby_spec.rb
47
+ - spec/spec_helper.rb
48
+ homepage: ''
49
+ licenses: []
50
+ post_install_message:
51
+ rdoc_options: []
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ! '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>'
64
+ - !ruby/object:Gem::Version
65
+ version: 1.3.1
66
+ requirements: []
67
+ rubyforge_project: moby
68
+ rubygems_version: 1.8.6
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: Ruby interface for Moby wordlists
72
+ test_files: []