wordnet 0.0.5 → 1.0.0.pre.126

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/.gemtest +0 -0
  2. data/History.rdoc +5 -0
  3. data/LICENSE +9 -9
  4. data/Manifest.txt +39 -0
  5. data/README.rdoc +60 -0
  6. data/Rakefile +47 -267
  7. data/TODO +9 -0
  8. data/WordNet30-license.txt +31 -0
  9. data/examples/add-laced-boots.rb +35 -0
  10. data/examples/clothes-with-collars.rb +42 -0
  11. data/examples/clothesWithTongues.rb +0 -0
  12. data/examples/domainTree.rb +0 -0
  13. data/examples/memberTree.rb +0 -0
  14. data/lib/wordnet/constants.rb +259 -296
  15. data/lib/wordnet/lexicallink.rb +34 -0
  16. data/lib/wordnet/lexicon.rb +158 -386
  17. data/lib/wordnet/mixins.rb +62 -0
  18. data/lib/wordnet/model.rb +78 -0
  19. data/lib/wordnet/morph.rb +25 -0
  20. data/lib/wordnet/semanticlink.rb +52 -0
  21. data/lib/wordnet/sense.rb +55 -0
  22. data/lib/wordnet/sumoterm.rb +21 -0
  23. data/lib/wordnet/synset.rb +404 -859
  24. data/lib/wordnet/utils.rb +126 -0
  25. data/lib/wordnet/word.rb +119 -0
  26. data/lib/wordnet.rb +113 -76
  27. data/spec/lib/helpers.rb +102 -133
  28. data/spec/linguawordnet.tests.rb +38 -0
  29. data/spec/wordnet/lexicon_spec.rb +96 -186
  30. data/spec/wordnet/model_spec.rb +59 -0
  31. data/spec/wordnet/semanticlink_spec.rb +42 -0
  32. data/spec/wordnet/synset_spec.rb +27 -256
  33. data/spec/wordnet/word_spec.rb +58 -0
  34. data/spec/wordnet_spec.rb +52 -0
  35. data.tar.gz.sig +0 -0
  36. metadata +227 -188
  37. metadata.gz.sig +0 -0
  38. data/ChangeLog +0 -720
  39. data/README +0 -93
  40. data/Rakefile.local +0 -46
  41. data/convertdb.rb +0 -417
  42. data/examples/addLacedBoots.rb +0 -27
  43. data/examples/clothesWithCollars.rb +0 -36
  44. data/rake/dependencies.rb +0 -76
  45. data/rake/helpers.rb +0 -384
  46. data/rake/manual.rb +0 -755
  47. data/rake/packaging.rb +0 -112
  48. data/rake/publishing.rb +0 -303
  49. data/rake/rdoc.rb +0 -35
  50. data/rake/style.rb +0 -62
  51. data/rake/svn.rb +0 -469
  52. data/rake/testing.rb +0 -192
  53. data/rake/verifytask.rb +0 -64
  54. data/utils.rb +0 -838
data/rake/packaging.rb DELETED
@@ -1,112 +0,0 @@
1
- #
2
- # Packaging Rake Tasks
3
- # $Id: packaging.rb 21 2008-08-07 23:45:52Z deveiant $
4
- #
5
-
6
- require 'rbconfig'
7
- require 'rake/packagetask'
8
- require 'rake/gempackagetask'
9
-
10
- include Config
11
-
12
- ### Task: gem
13
- ### Task: package
14
- Rake::PackageTask.new( PKG_NAME, PKG_VERSION ) do |task|
15
- task.need_tar_gz = true
16
- task.need_tar_bz2 = true
17
- task.need_zip = true
18
- task.package_dir = PKGDIR.to_s
19
- task.package_files = RELEASE_FILES.
20
- collect {|f| f.relative_path_from(BASEDIR).to_s }
21
- end
22
- task :package => [:gem]
23
-
24
-
25
- ### Task: gem
26
- gempath = PKGDIR + GEM_FILE_NAME
27
-
28
- desc "Build a RubyGem package (#{GEM_FILE_NAME})"
29
- task :gem => gempath.to_s
30
- file gempath.to_s => [PKGDIR.to_s] + GEMSPEC.files do
31
- when_writing( "Creating GEM" ) do
32
- Gem::Builder.new( GEMSPEC ).build
33
- verbose( true ) do
34
- mv GEM_FILE_NAME, gempath
35
- end
36
- end
37
- end
38
-
39
- ### Task: install
40
- desc "Install #{PKG_NAME} as a conventional library"
41
- task :install do
42
- log "Installing #{PKG_NAME} as a conventional library"
43
- sitelib = Pathname.new( CONFIG['sitelibdir'] )
44
- sitearch = Pathname.new( CONFIG['sitearchdir'] )
45
- Dir.chdir( LIBDIR ) do
46
- LIB_FILES.each do |libfile|
47
- relpath = libfile.relative_path_from( LIBDIR )
48
- target = sitelib + relpath
49
- FileUtils.mkpath target.dirname,
50
- :mode => 0755, :verbose => true, :noop => $dryrun unless target.dirname.directory?
51
- FileUtils.install relpath, target,
52
- :mode => 0644, :verbose => true, :noop => $dryrun
53
- end
54
- end
55
- if EXTDIR.exist?
56
- Dir.chdir( EXTDIR ) do
57
- Pathname.glob( EXTDIR + Config::CONFIG['DLEXT'] ) do |dl|
58
- target = sitearch + dl.basename
59
- FileUtils.install dl, target,
60
- :mode => 0755, :verbose => true, :noop => $dryrun
61
- end
62
- end
63
- end
64
- end
65
-
66
-
67
-
68
- ### Task: install_gem
69
- desc "Install #{PKG_NAME} from a locally-built gem"
70
- task :install_gem => [:package] do
71
- $stderr.puts
72
- installer = Gem::Installer.new( %{pkg/#{PKG_FILE_NAME}.gem} )
73
- installer.install
74
- end
75
-
76
-
77
- ### Task: uninstall
78
- desc "Uninstall #{PKG_NAME} if it's been installed as a conventional library"
79
- task :uninstall do
80
- log "Uninstalling conventionally-installed #{PKG_NAME} library files"
81
- sitelib = Pathname.new( CONFIG['sitelibdir'] )
82
- sitearch = Pathname.new( CONFIG['sitearchdir'] )
83
-
84
- Dir.chdir( LIBDIR ) do
85
- LIB_FILES.each do |libfile|
86
- relpath = libfile.relative_path_from( LIBDIR )
87
- target = sitelib + relpath
88
- FileUtils.rm_f target, :verbose => true, :noop => $dryrun
89
- FileUtils.rm_rf( target.dirname, :verbose => true, :noop => $dryrun ) if
90
- target.dirname.entries.empty?
91
- end
92
- end
93
- if EXTDIR.exist?
94
- Dir.chdir( EXTDIR ) do
95
- Pathname.glob( EXTDIR + Config::CONFIG['DLEXT'] ) do |dl|
96
- target = sitearch + dl.basename
97
- FileUtils.rm target, :verbose => true, :noop => $dryrun
98
- end
99
- end
100
- end
101
- end
102
-
103
-
104
- ### Task: uninstall_gem
105
- desc "Install the #{PKG_NAME} gem"
106
- task :uninstall_gem => [:clean] do
107
- uninstaller = Gem::Uninstaller.new( PKG_FILE_NAME )
108
- uninstaller.uninstall
109
- end
110
-
111
-
112
-
data/rake/publishing.rb DELETED
@@ -1,303 +0,0 @@
1
- #####################################################################
2
- ### P U B L I C A T I O N T A S K S
3
- #####################################################################
4
-
5
- RELEASE_NOTES_FILE = 'release.notes'
6
- RELEASE_ANNOUNCE_FILE = 'release.ann'
7
-
8
- require 'net/smtp'
9
- require 'net/protocol'
10
- require 'openssl'
11
-
12
- $publish_privately = false
13
-
14
- ### Add SSL to Net::SMTP
15
- class Net::SMTP
16
- def ssl_start( helo='localhost.localdomain', user=nil, secret=nil, authtype=nil )
17
- if block_given?
18
- begin
19
- do_ssl_start( helo, user, secret, authtype )
20
- return yield( self )
21
- ensure
22
- do_finish
23
- end
24
- else
25
- do_ssl_start( helo, user, secret, authtype )
26
- return self
27
- end
28
- end
29
-
30
-
31
- #######
32
- private
33
- #######
34
-
35
- def do_ssl_start( helodomain, user, secret, authtype )
36
- raise IOError, 'SMTP session already started' if @started
37
- check_auth_args user, secret, authtype if user or secret
38
-
39
- # Open the connection
40
- @debug_output << "opening connection to #{@address}...\n" if @debug_output
41
- sock = timeout( @open_timeout ) { TCPsocket.new(@address, @port) }
42
-
43
- # Wrap it in the SSL layer
44
- ssl_context = OpenSSL::SSL::SSLContext.new
45
- ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE
46
- ssl_sock = OpenSSL::SSL::SSLSocket.new( sock, ssl_context )
47
- ssl_sock.sync_close = true
48
- ssl_sock.connect
49
-
50
- # Wrap it in the message-oriented IO layer
51
- sslmsgio = Net::InternetMessageIO.new( ssl_sock )
52
- sslmsgio.read_timeout = @read_timeout
53
- sslmsgio.debug_output = @debug_output
54
-
55
- @socket = sslmsgio
56
-
57
- check_response(critical { recv_response() })
58
- begin
59
- if @esmtp
60
- ehlo helodomain
61
- else
62
- helo helodomain
63
- end
64
- rescue ProtocolError
65
- if @esmtp
66
- @esmtp = false
67
- @error_occured = false
68
- retry
69
- end
70
- raise
71
- end
72
- authenticate user, secret, authtype if user
73
- @started = true
74
- ensure
75
- @socket.close if not @started and @socket and not @socket.closed?
76
- end
77
- end
78
-
79
-
80
- begin
81
- gem 'text-format'
82
-
83
- require 'time'
84
- require 'rake/tasklib'
85
- require 'tmail'
86
- require 'net/smtp'
87
- require 'etc'
88
- require 'rubyforge'
89
- require 'socket'
90
- require 'text/format'
91
-
92
- ### Generate a valid RFC822 message-id
93
- def gen_message_id
94
- return "<%s.%s@%s>" % [
95
- (Time.now.to_f * 10000).to_i.to_s( 36 ),
96
- (rand( 2 ** 64 - 1 )).to_s( 36 ),
97
- Socket.gethostname
98
- ]
99
- end
100
-
101
-
102
- namespace :release do
103
- task :default => [ 'svn:release', :publish, :announce, :project ]
104
-
105
- desc "Re-publish the release with the current version number"
106
- task :rerelease => [ :publish, :announce, :project ]
107
-
108
- task :test do
109
- trace "Will publish privately"
110
- $publish_privately = true
111
- Rake::Task['release:rerelease'].invoke
112
- end
113
-
114
-
115
- desc "Generate the release notes"
116
- task :notes => [RELEASE_NOTES_FILE]
117
- file RELEASE_NOTES_FILE do |task|
118
- last_rel_tag = get_latest_release_tag() or
119
- fail ">>> No releases tagged! Try running 'rake svn:release' first"
120
- trace "Last release tag is: %p" % [ last_rel_tag ]
121
- start = get_last_changed_rev( last_rel_tag ) || 1
122
- trace "Starting rev is: %p" % [ start ]
123
- log_output = make_svn_log( '.', start, 'HEAD' )
124
-
125
- File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
126
- fh.print( log_output )
127
- end
128
-
129
- edit task.name
130
- end
131
- CLOBBER.include( RELEASE_NOTES_FILE )
132
-
133
-
134
- task :project => [ :rdoc ] do
135
- when_writing( "Publishing docs to #{PROJECT_SCPDOCURL}" ) do
136
- run 'ssh', PROJECT_HOST, "rm -rf #{PROJECT_DOCDIR}"
137
- run 'scp', '-qCr', 'docs/html', PROJECT_SCPDOCURL
138
- end
139
- when_writing( "Uploading packages") do
140
- pkgs = Pathname.glob( PKGDIR + "#{PKG_FILE_NAME}.{gem,tar.gz,tar.bz2,zip}" )
141
- log "Uploading %d packages to #{PROJECT_SCPPUBURL}" % [ pkgs.length ]
142
- pkgs.each do |pkgfile|
143
- run 'scp', '-qC', pkgfile, PROJECT_SCPPUBURL
144
- end
145
- end
146
- end
147
-
148
-
149
- file RELEASE_ANNOUNCE_FILE => [RELEASE_NOTES_FILE] do |task|
150
- relnotes = File.read( RELEASE_NOTES_FILE )
151
- announce_body = %{
152
-
153
- Version #{PKG_VERSION} of #{PKG_NAME} has been released.
154
-
155
- #{Text::Format.new(:first_indent => 0).format_one_paragraph(GEMSPEC.description)}
156
-
157
- == Project Page
158
-
159
- #{GEMSPEC.homepage}
160
-
161
- == Installation
162
-
163
- Via gems:
164
-
165
- $ sudo gem install #{GEMSPEC.name}
166
-
167
- or from source:
168
-
169
- $ wget http://deveiate.org/code/#{PKG_FILE_NAME}.tar.gz
170
- $ tar -xzvf #{PKG_FILE_NAME}.tar.gz
171
- $ cd #{PKG_FILE_NAME}
172
- $ sudo rake install
173
-
174
- == Changes
175
- #{relnotes}
176
- }.gsub( /^\t+/, '' )
177
-
178
- File.open( task.name, File::WRONLY|File::TRUNC|File::CREAT ) do |fh|
179
- fh.print( announce_body )
180
- end
181
-
182
- edit task.name
183
- end
184
- CLOBBER.include( RELEASE_ANNOUNCE_FILE )
185
-
186
-
187
- desc 'Send out a release announcement'
188
- task :announce => [RELEASE_ANNOUNCE_FILE] do
189
- email = TMail::Mail.new
190
- if $publish_privately
191
- trace "Sending private announce mail"
192
- email.to = 'rubymage@gmail.com'
193
- else
194
- trace "Sending public announce mail"
195
- email.to = 'Ruby-Talk List <ruby-talk@ruby-lang.org>'
196
- email.bcc = 'rubymage@gmail.com'
197
- end
198
- email.from = GEMSPEC.email
199
- email.subject = "[ANN] #{PKG_NAME} #{PKG_VERSION}"
200
- email.body = File.read( RELEASE_ANNOUNCE_FILE )
201
- email.date = Time.new
202
-
203
- email.message_id = gen_message_id()
204
-
205
- log "About to send the following email:"
206
- puts '---',
207
- email.to_s,
208
- '---'
209
-
210
- ask_for_confirmation( "Will send via #{SMTP_HOST}." ) do
211
- pwent = Etc.getpwuid( Process.euid )
212
- curuser = pwent ? pwent.name : 'unknown'
213
- username = prompt_with_default( "SMTP user", curuser )
214
- password = prompt_for_password()
215
-
216
- trace "Creating SMTP connection to #{SMTP_HOST}:#{SMTP_PORT}"
217
- smtp = Net::SMTP.new( SMTP_HOST, SMTP_PORT )
218
- smtp.set_debug_output( $stdout )
219
- smtp.esmtp = true
220
-
221
- trace "connecting..."
222
- smtp.ssl_start( Socket.gethostname, username, password, :plain ) do |smtp|
223
- trace "sending message..."
224
- smtp.send_message( email.to_s, email.from, email.to )
225
- end
226
- trace "done."
227
- end
228
- end
229
-
230
-
231
- desc 'Publish the new release to RubyForge'
232
- task :publish => [:clean, :package, :notes] do |task|
233
- project = GEMSPEC.rubyforge_project
234
-
235
- rf = RubyForge.new
236
- log "Loading RubyForge config"
237
- rf.configure
238
-
239
- group_id = rf.autoconfig['group_ids'][RUBYFORGE_GROUP] or
240
- fail "Your configuration doesn't have a group id for '#{RUBYFORGE_GROUP}'"
241
-
242
- # If this project doesn't yet exist, create it
243
- unless rf.autoconfig['package_ids'].key?( project )
244
- ask_for_confirmation( "Package '#{project}' doesn't exist on RubyForge. Create it?" ) do
245
- log "Creating new package '#{project}'"
246
- rf.create_package( group_id, project )
247
- end
248
- end
249
-
250
- package_id = rf.autoconfig['package_ids'][ project ]
251
-
252
- # Make sure this release doesn't already exist
253
- releases = rf.autoconfig['release_ids']
254
- if releases.key?( GEMSPEC.name ) && releases[ GEMSPEC.name ].key?( PKG_VERSION )
255
- log "Rubyforge seems to already have #{ PKG_FILE_NAME }"
256
- else
257
- config = rf.userconfig or
258
- fail "You apparently haven't set up your RubyForge credentials on this machine."
259
- config['release_notes'] = GEMSPEC.description
260
- config['release_changes'] = File.read( RELEASE_NOTES_FILE )
261
-
262
- files = FileList[ PKGDIR + GEM_FILE_NAME ]
263
- files.include PKGDIR + "#{PKG_FILE_NAME}.tar.gz"
264
- files.include PKGDIR + "#{PKG_FILE_NAME}.tar.bz2"
265
- files.include PKGDIR + "#{PKG_FILE_NAME}.zip"
266
-
267
- log "Releasing #{PKG_FILE_NAME}"
268
- when_writing do
269
- log "Publishing to RubyForge: \n",
270
- "\tproject: #{RUBYFORGE_GROUP}\n",
271
- "\tpackage: #{PKG_NAME.downcase}\n",
272
- "\tpackage version: #{PKG_VERSION}\n",
273
- "\tfiles: " + files.collect {|f| f.to_s }.join(', ') + "\n"
274
-
275
- ask_for_confirmation( "Publish to RubyForge?" ) do
276
- log 'Logging in...'
277
- rf.login
278
- log "Adding the new release to the '#{project}' project"
279
- rf.add_release( group_id, package_id, PKG_VERSION, *files )
280
- end
281
- end
282
- end
283
- end
284
- end
285
-
286
- rescue LoadError => err
287
- if !Object.const_defined?( :Gem )
288
- require 'rubygems'
289
- retry
290
- end
291
-
292
- task :no_release_tasks do
293
- fail "Release tasks not defined: #{err.message}"
294
- end
295
-
296
- task :release => :no_release_tasks
297
- task "release:announce" => :no_release_tasks
298
- task "release:publish" => :no_release_tasks
299
- task "release:notes" => :no_release_tasks
300
- end
301
-
302
- task :release => 'release:default'
303
-
data/rake/rdoc.rb DELETED
@@ -1,35 +0,0 @@
1
- #
2
- # RDoc Rake tasks for ThingFish
3
- # $Id: rdoc.rb 40 2008-08-27 21:58:00Z deveiant $
4
- #
5
-
6
- require 'rake/rdoctask'
7
- $have_darkfish = false
8
-
9
- # Append docs/lib to the load path if it exists for a locally-installed Darkfish
10
- DOCSLIB = DOCSDIR + 'lib'
11
- $LOAD_PATH.unshift( DOCSLIB.to_s ) if DOCSLIB.exist?
12
-
13
- begin
14
- require 'darkfish-rdoc'
15
- $have_darkfish = true
16
- rescue LoadError => err
17
- unless Object.const_defined?( :Gem )
18
- require 'rubygems'
19
- gem 'darkfish-rdoc'
20
- retry
21
- end
22
-
23
- log "No DarkFish: %s: %s" % [ err.class.name, err.message ]
24
- trace "Backtrace:\n %s" % [ err.backtrace.join("\n ") ]
25
- end
26
-
27
- Rake::RDocTask.new do |rdoc|
28
- rdoc.rdoc_dir = RDOCDIR.expand_path.relative_path_from( Pathname.pwd ).to_s
29
- rdoc.title = "#{PKG_NAME} - #{PKG_SUMMARY}"
30
- rdoc.options += RDOC_OPTIONS + [ '-f', 'darkfish' ] if $have_darkfish
31
-
32
- rdoc.rdoc_files.include 'README'
33
- rdoc.rdoc_files.include LIB_FILES.collect {|f| f.to_s }
34
- rdoc.rdoc_files.include EXT_FILES.collect {|f| f.to_s }
35
- end
data/rake/style.rb DELETED
@@ -1,62 +0,0 @@
1
- #
2
- # Style Fixup Rake Tasks
3
- # $Id: style.rb 10 2008-07-18 15:52:48Z deveiant $
4
- #
5
- # Authors:
6
- # * Michael Granger <ged@FaerieMUD.org>
7
- #
8
-
9
-
10
- ### Coding style checks and fixes
11
- namespace :style do
12
-
13
- BLANK_LINE = /^\s*$/
14
- GOOD_INDENT = /^(\t\s*)?\S/
15
-
16
- # A list of the files that have legitimate leading whitespace, etc.
17
- PROBLEM_FILES = [ SPECDIR + 'config_spec.rb' ]
18
-
19
- desc "Check source files for inconsistent indent and fix them"
20
- task :fix_indent do
21
- files = LIB_FILES + SPEC_FILES
22
-
23
- badfiles = Hash.new {|h,k| h[k] = [] }
24
-
25
- trace "Checking files for indentation"
26
- files.each do |file|
27
- if PROBLEM_FILES.include?( file )
28
- trace " skipping problem file #{file}..."
29
- next
30
- end
31
-
32
- trace " #{file}"
33
- linecount = 0
34
- file.each_line do |line|
35
- linecount += 1
36
-
37
- # Skip blank lines
38
- next if line =~ BLANK_LINE
39
-
40
- # If there's a line with incorrect indent, note it and skip to the
41
- # next file
42
- if line !~ GOOD_INDENT
43
- trace " Bad line %d: %p" % [ linecount, line ]
44
- badfiles[file] << [ linecount, line ]
45
- end
46
- end
47
- end
48
-
49
- if badfiles.empty?
50
- log "No indentation problems found."
51
- else
52
- log "Found incorrect indent in #{badfiles.length} files:\n "
53
- badfiles.each do |file, badlines|
54
- log " #{file}:\n" +
55
- " " + badlines.collect {|badline| "%5d: %p" % badline }.join( "\n " )
56
- end
57
- end
58
- end
59
-
60
- end
61
-
62
-