wordnet 0.0.5 → 1.0.0.pre.126
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/.gemtest +0 -0
- data/History.rdoc +5 -0
- data/LICENSE +9 -9
- data/Manifest.txt +39 -0
- data/README.rdoc +60 -0
- data/Rakefile +47 -267
- data/TODO +9 -0
- data/WordNet30-license.txt +31 -0
- data/examples/add-laced-boots.rb +35 -0
- data/examples/clothes-with-collars.rb +42 -0
- data/examples/clothesWithTongues.rb +0 -0
- data/examples/domainTree.rb +0 -0
- data/examples/memberTree.rb +0 -0
- data/lib/wordnet/constants.rb +259 -296
- data/lib/wordnet/lexicallink.rb +34 -0
- data/lib/wordnet/lexicon.rb +158 -386
- data/lib/wordnet/mixins.rb +62 -0
- data/lib/wordnet/model.rb +78 -0
- data/lib/wordnet/morph.rb +25 -0
- data/lib/wordnet/semanticlink.rb +52 -0
- data/lib/wordnet/sense.rb +55 -0
- data/lib/wordnet/sumoterm.rb +21 -0
- data/lib/wordnet/synset.rb +404 -859
- data/lib/wordnet/utils.rb +126 -0
- data/lib/wordnet/word.rb +119 -0
- data/lib/wordnet.rb +113 -76
- data/spec/lib/helpers.rb +102 -133
- data/spec/linguawordnet.tests.rb +38 -0
- data/spec/wordnet/lexicon_spec.rb +96 -186
- data/spec/wordnet/model_spec.rb +59 -0
- data/spec/wordnet/semanticlink_spec.rb +42 -0
- data/spec/wordnet/synset_spec.rb +27 -256
- data/spec/wordnet/word_spec.rb +58 -0
- data/spec/wordnet_spec.rb +52 -0
- data.tar.gz.sig +0 -0
- metadata +227 -188
- metadata.gz.sig +0 -0
- data/ChangeLog +0 -720
- data/README +0 -93
- data/Rakefile.local +0 -46
- data/convertdb.rb +0 -417
- data/examples/addLacedBoots.rb +0 -27
- data/examples/clothesWithCollars.rb +0 -36
- data/rake/dependencies.rb +0 -76
- data/rake/helpers.rb +0 -384
- data/rake/manual.rb +0 -755
- data/rake/packaging.rb +0 -112
- data/rake/publishing.rb +0 -303
- data/rake/rdoc.rb +0 -35
- data/rake/style.rb +0 -62
- data/rake/svn.rb +0 -469
- data/rake/testing.rb +0 -192
- data/rake/verifytask.rb +0 -64
- data/utils.rb +0 -838
data/lib/wordnet/constants.rb
CHANGED
@@ -1,301 +1,264 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
|
-
|
2
|
+
|
3
|
+
require 'wordnet' unless defined?( WordNet )
|
4
|
+
|
3
5
|
# This is a module containing constants used in the WordNet interface for
|
4
6
|
# Ruby. They are contained in a module to facilitate their easy inclusion in
|
5
7
|
# other namespaces. All constants in this module are also contained in the
|
6
8
|
# WordNet namespace itself.
|
7
|
-
|
8
|
-
|
9
|
-
#
|
10
|
-
|
11
|
-
|
12
|
-
#
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
#
|
21
|
-
|
22
|
-
|
23
|
-
#
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
#
|
30
|
-
#
|
31
|
-
|
32
|
-
#
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
#
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
#
|
104
|
-
|
105
|
-
|
106
|
-
#
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
"Something ----s Adjective/Noun",
|
264
|
-
"Somebody ----s Adjective",
|
265
|
-
"Somebody ----s something",
|
266
|
-
"Somebody ----s somebody",
|
267
|
-
"Something ----s somebody",
|
268
|
-
"Something ----s something",
|
269
|
-
"Something ----s to somebody",
|
270
|
-
"Somebody ----s on something",
|
271
|
-
"Somebody ----s somebody something",
|
272
|
-
"Somebody ----s something to somebody",
|
273
|
-
"Somebody ----s something from somebody",
|
274
|
-
"Somebody ----s somebody with something",
|
275
|
-
"Somebody ----s somebody of something",
|
276
|
-
"Somebody ----s something on somebody",
|
277
|
-
"Somebody ----s somebody PP",
|
278
|
-
"Somebody ----s something PP",
|
279
|
-
"Somebody ----s PP",
|
280
|
-
"Somebody's (body part) ----s",
|
281
|
-
"Somebody ----s somebody to INFINITIVE",
|
282
|
-
"Somebody ----s somebody INFINITIVE",
|
283
|
-
"Somebody ----s that CLAUSE",
|
284
|
-
"Somebody ----s to somebody",
|
285
|
-
"Somebody ----s to INFINITIVE",
|
286
|
-
"Somebody ----s whether INFINITIVE",
|
287
|
-
"Somebody ----s somebody into V-ing something",
|
288
|
-
"Somebody ----s something with something",
|
289
|
-
"Somebody ----s INFINITIVE",
|
290
|
-
"Somebody ----s VERB-ing",
|
291
|
-
"It ----s that CLAUSE",
|
292
|
-
"Something ----s INFINITIVE"
|
293
|
-
]
|
294
|
-
|
295
|
-
|
296
|
-
end # module Constants
|
297
|
-
|
298
|
-
# Make the constants available under the WordNet namespace, too.
|
299
|
-
include Constants
|
300
|
-
|
301
|
-
end # module WordNet
|
9
|
+
module WordNet::Constants
|
10
|
+
|
11
|
+
# The default database options
|
12
|
+
DEFAULT_DB_OPTIONS = {}
|
13
|
+
|
14
|
+
# Synset syntactic-category names -> indicators
|
15
|
+
SYNTACTIC_CATEGORIES = {
|
16
|
+
:noun => "n",
|
17
|
+
:verb => "v",
|
18
|
+
:adjective => "a",
|
19
|
+
:adverb => "r",
|
20
|
+
:other => "s",
|
21
|
+
}
|
22
|
+
# Syntactic-category indicators -> names
|
23
|
+
SYNTACTIC_SYMBOLS = SYNTACTIC_CATEGORIES.invert
|
24
|
+
|
25
|
+
# Map the categories into their own constants (eg., Noun)
|
26
|
+
SYNTACTIC_CATEGORIES.each do |sym,val|
|
27
|
+
cname = sym.to_s.capitalize
|
28
|
+
const_set( cname, val )
|
29
|
+
end
|
30
|
+
|
31
|
+
# Information about pointer types is contained in the wninput(5WN)
|
32
|
+
# manpage.
|
33
|
+
|
34
|
+
# Synset pointer typenames -> indicators
|
35
|
+
POINTER_TYPES = {
|
36
|
+
:antonym => '!',
|
37
|
+
:hypernym => '@',
|
38
|
+
:entailment => '*',
|
39
|
+
:hyponym => '~',
|
40
|
+
:meronym => '%',
|
41
|
+
:holonym => '#',
|
42
|
+
:cause => '>',
|
43
|
+
:verb_group => '$',
|
44
|
+
:similar_to => '&',
|
45
|
+
:participle => '<',
|
46
|
+
:pertainym => '\\',
|
47
|
+
:attribute => '=',
|
48
|
+
:derived_from => '\\',
|
49
|
+
:see_also => '^',
|
50
|
+
:derivation => '+',
|
51
|
+
:domain => ';',
|
52
|
+
:member => '-',
|
53
|
+
}
|
54
|
+
|
55
|
+
# Synset pointer indicator -> typename
|
56
|
+
POINTER_SYMBOLS = POINTER_TYPES.invert
|
57
|
+
|
58
|
+
# Map the pointer types into their own symbols (eg., :verb_group => VerbGroup)
|
59
|
+
POINTER_TYPES.each do |sym,val|
|
60
|
+
cname = sym.to_s.gsub( /(?:^|_)(.)/ ) { $1.upcase }
|
61
|
+
const_set( cname, val )
|
62
|
+
end
|
63
|
+
|
64
|
+
# Hypernym synset pointer types
|
65
|
+
HYPERNYM_TYPES = {
|
66
|
+
nil => '@', # Install non-subtype methods, too
|
67
|
+
:instance => '@i',
|
68
|
+
}
|
69
|
+
|
70
|
+
# Hypernym indicator -> type map
|
71
|
+
HYPERNYM_SYMBOLS = HYPERNYM_TYPES.invert
|
72
|
+
|
73
|
+
# Hyponym synset pointer types
|
74
|
+
HYPONYM_TYPES = {
|
75
|
+
nil => '~', # Install non-subtype methods, too
|
76
|
+
:instance => '~i',
|
77
|
+
}
|
78
|
+
|
79
|
+
# Hyponym indicator -> type map
|
80
|
+
HYPONYM_SYMBOLS = HYPONYM_TYPES.invert
|
81
|
+
|
82
|
+
# Meronym synset pointer types
|
83
|
+
MERONYM_TYPES = {
|
84
|
+
:member => '%m',
|
85
|
+
:stuff => '%s',
|
86
|
+
:portion => '%o',
|
87
|
+
:component => '%p',
|
88
|
+
:feature => '%f',
|
89
|
+
:phase => '%a',
|
90
|
+
:place => '%l',
|
91
|
+
}
|
92
|
+
|
93
|
+
# Meronym indicator -> type map
|
94
|
+
MERONYM_SYMBOLS = MERONYM_TYPES.invert
|
95
|
+
|
96
|
+
# Map the meronym types into their own constants (eg., MemberMeronym)
|
97
|
+
MERONYM_TYPES.each do |sym,val|
|
98
|
+
cname = sym.to_s.capitalize + "Meronym"
|
99
|
+
const_set( cname, val )
|
100
|
+
end
|
101
|
+
|
102
|
+
# Holonym synset pointer types
|
103
|
+
HOLONYM_TYPES = {
|
104
|
+
:member => '#m',
|
105
|
+
:stuff => '#s',
|
106
|
+
:portion => '#o',
|
107
|
+
:component => '#p',
|
108
|
+
:feature => '#f',
|
109
|
+
:phase => '#a',
|
110
|
+
:place => '#l',
|
111
|
+
}
|
112
|
+
|
113
|
+
# Holonym indicator -> type map
|
114
|
+
HOLONYM_SYMBOLS = HOLONYM_TYPES.invert
|
115
|
+
|
116
|
+
# Map the holonym types into their own constants (eg., MemberHolonym)
|
117
|
+
HOLONYM_TYPES.each do |sym,val|
|
118
|
+
cname = sym.to_s.capitalize + "Holonym"
|
119
|
+
const_set( cname, val )
|
120
|
+
end
|
121
|
+
|
122
|
+
# Domain synset pointer types
|
123
|
+
DOMAIN_TYPES = {
|
124
|
+
:category => ';c',
|
125
|
+
:region => ';r',
|
126
|
+
:usage => ';u',
|
127
|
+
}
|
128
|
+
|
129
|
+
# Domain indicator -> type map
|
130
|
+
DomainSymbols = DOMAIN_TYPES.invert
|
131
|
+
|
132
|
+
# Map the domain types into their own constants (eg., CategoryDomain)
|
133
|
+
DOMAIN_TYPES.each do |sym,val|
|
134
|
+
cname = sym.to_s.capitalize + "Domain"
|
135
|
+
const_set( cname, val )
|
136
|
+
end
|
137
|
+
|
138
|
+
# Member synset pointer types
|
139
|
+
MEMBER_TYPES = {
|
140
|
+
:category => '-c',
|
141
|
+
:region => '-r',
|
142
|
+
:usage => '-u',
|
143
|
+
}
|
144
|
+
|
145
|
+
# Member indicator -> type map
|
146
|
+
MEMBER_SYMBOLS = MEMBER_TYPES.invert
|
147
|
+
|
148
|
+
# Map the member types into their own constants (eg., CategoryMember)
|
149
|
+
MEMBER_TYPES.each do |sym,val|
|
150
|
+
cname = sym.to_s.capitalize + "Member"
|
151
|
+
const_set( cname, val )
|
152
|
+
end
|
153
|
+
|
154
|
+
# Map of primary types to maps of their subtypes
|
155
|
+
POINTER_SUBTYPES = {
|
156
|
+
:hyponym => HYPONYM_TYPES,
|
157
|
+
:hypernym => HYPERNYM_TYPES,
|
158
|
+
:meronym => MERONYM_TYPES,
|
159
|
+
:holonym => HOLONYM_TYPES,
|
160
|
+
:member => MEMBER_TYPES,
|
161
|
+
:domain => DOMAIN_TYPES,
|
162
|
+
}
|
163
|
+
|
164
|
+
|
165
|
+
# Record-part delimiter
|
166
|
+
DELIM = '||'
|
167
|
+
DELIM_RE = Regexp::new( Regexp::quote(DELIM) )
|
168
|
+
|
169
|
+
# Record-subpart delimiter
|
170
|
+
SUB_DELIM = '|'
|
171
|
+
SUB_DELIM_RE = Regexp::new( Regexp::quote(SUB_DELIM) )
|
172
|
+
|
173
|
+
# Lexicographer file index -- from lexnames(5WN)
|
174
|
+
LEXFILES = [
|
175
|
+
"adj.all",
|
176
|
+
"adj.pert",
|
177
|
+
"adv.all",
|
178
|
+
"noun.Tops",
|
179
|
+
"noun.act",
|
180
|
+
"noun.animal",
|
181
|
+
"noun.artifact",
|
182
|
+
"noun.attribute",
|
183
|
+
"noun.body",
|
184
|
+
"noun.cognition",
|
185
|
+
"noun.communication",
|
186
|
+
"noun.event",
|
187
|
+
"noun.feeling",
|
188
|
+
"noun.food",
|
189
|
+
"noun.group",
|
190
|
+
"noun.location",
|
191
|
+
"noun.motive",
|
192
|
+
"noun.object",
|
193
|
+
"noun.person",
|
194
|
+
"noun.phenomenon",
|
195
|
+
"noun.plant",
|
196
|
+
"noun.possession",
|
197
|
+
"noun.process",
|
198
|
+
"noun.quantity",
|
199
|
+
"noun.relation",
|
200
|
+
"noun.shape",
|
201
|
+
"noun.state",
|
202
|
+
"noun.substance",
|
203
|
+
"noun.time",
|
204
|
+
"verb.body",
|
205
|
+
"verb.change",
|
206
|
+
"verb.cognition",
|
207
|
+
"verb.communication",
|
208
|
+
"verb.competition",
|
209
|
+
"verb.consumption",
|
210
|
+
"verb.contact",
|
211
|
+
"verb.creation",
|
212
|
+
"verb.emotion",
|
213
|
+
"verb.motion",
|
214
|
+
"verb.perception",
|
215
|
+
"verb.possession",
|
216
|
+
"verb.social",
|
217
|
+
"verb.stative",
|
218
|
+
"verb.weather",
|
219
|
+
"adj.ppl"
|
220
|
+
]
|
221
|
+
|
222
|
+
# Verb sentences (?) -- used in building verb frames.
|
223
|
+
VERB_SENTS = [
|
224
|
+
"",
|
225
|
+
"Something ----s",
|
226
|
+
"Somebody ----s",
|
227
|
+
"It is ----ing",
|
228
|
+
"Something is ----ing PP",
|
229
|
+
"Something ----s something Adjective/Noun",
|
230
|
+
"Something ----s Adjective/Noun",
|
231
|
+
"Somebody ----s Adjective",
|
232
|
+
"Somebody ----s something",
|
233
|
+
"Somebody ----s somebody",
|
234
|
+
"Something ----s somebody",
|
235
|
+
"Something ----s something",
|
236
|
+
"Something ----s to somebody",
|
237
|
+
"Somebody ----s on something",
|
238
|
+
"Somebody ----s somebody something",
|
239
|
+
"Somebody ----s something to somebody",
|
240
|
+
"Somebody ----s something from somebody",
|
241
|
+
"Somebody ----s somebody with something",
|
242
|
+
"Somebody ----s somebody of something",
|
243
|
+
"Somebody ----s something on somebody",
|
244
|
+
"Somebody ----s somebody PP",
|
245
|
+
"Somebody ----s something PP",
|
246
|
+
"Somebody ----s PP",
|
247
|
+
"Somebody's (body part) ----s",
|
248
|
+
"Somebody ----s somebody to INFINITIVE",
|
249
|
+
"Somebody ----s somebody INFINITIVE",
|
250
|
+
"Somebody ----s that CLAUSE",
|
251
|
+
"Somebody ----s to somebody",
|
252
|
+
"Somebody ----s to INFINITIVE",
|
253
|
+
"Somebody ----s whether INFINITIVE",
|
254
|
+
"Somebody ----s somebody into V-ing something",
|
255
|
+
"Somebody ----s something with something",
|
256
|
+
"Somebody ----s INFINITIVE",
|
257
|
+
"Somebody ----s VERB-ing",
|
258
|
+
"It ----s that CLAUSE",
|
259
|
+
"Something ----s INFINITIVE"
|
260
|
+
]
|
261
|
+
|
262
|
+
|
263
|
+
end # module Wordnet::Constants
|
264
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
require 'wordnet' unless defined?( WordNet )
|
4
|
+
require 'wordnet/synset' unless defined?( WordNet::Synset )
|
5
|
+
require 'wordnet/model'
|
6
|
+
|
7
|
+
# WordNet lexical link (pointer) model class
|
8
|
+
class WordNet::LexicalLink < WordNet::Model( :lexlinks )
|
9
|
+
include WordNet::Constants
|
10
|
+
|
11
|
+
set_primary_key [:word1id, :synset1id, :word2id, :synset2id, :linkid]
|
12
|
+
|
13
|
+
many_to_one :origin,
|
14
|
+
:class => :"WordNet::Sense",
|
15
|
+
:key => :synset1id,
|
16
|
+
:primary_key => :synsetid
|
17
|
+
|
18
|
+
one_to_many :target,
|
19
|
+
:class => :"WordNet::Synset",
|
20
|
+
:key => :synsetid,
|
21
|
+
:primary_key => :synset2id
|
22
|
+
|
23
|
+
|
24
|
+
######
|
25
|
+
public
|
26
|
+
######
|
27
|
+
|
28
|
+
### Return the type of link this is as a Symbol.
|
29
|
+
def type
|
30
|
+
return WordNet::Synset.linktype_table[ self.linkid ][ :type ]
|
31
|
+
end
|
32
|
+
|
33
|
+
end # class WordNet::SemanticLink
|
34
|
+
|