wordnet 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,27 @@
1
+ Copyright (c) 2008, Michael Granger
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ * Neither the name of the author/s, nor the names of the project's
15
+ contributors may be used to endorse or promote products derived from this
16
+ software without specific prior written permission.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
22
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README ADDED
@@ -0,0 +1,93 @@
1
+ = Ruby-WordNet
2
+ == General Information
3
+
4
+ This library is a Ruby interface to WordNet�. WordNet� is an online lexical
5
+ reference system whose design is inspired by current psycholinguistic theories
6
+ of human lexical memory. English nouns, verbs, adjectives and adverbs are
7
+ organized into synonym sets, each representing one underlying lexical
8
+ concept. Different relations link the synonym sets.
9
+
10
+ You can find out more about WordNet� at <http://wordnet.princeton.edu/>.
11
+
12
+ This code was loosely based on the Lingua::Wordnet Perl module by Dan Brian, and
13
+ uses a similar strategy of converting the WordNet data files into a BerkeleyDB
14
+ database. The 'convertdb.rb' script in this directory can be used to build these
15
+ databases from the WordNet dictionaries.
16
+
17
+ This module is intended to offer basically the same functionality as
18
+ Lingua::Wordnet, and you should be able to use either (or both) to access and
19
+ modify the lexical database interchangeably. This module attempts to remain
20
+ fairly close in API to Lingua::Wordnet, so if you're familiar with it already,
21
+ you should be able to port things from one to the other with relatively little
22
+ trouble. This module, however, uses BerkeleyDB's transaction subsystem to allow
23
+ safe concurrent access to the databases.
24
+
25
+ Many thanks to Dan Brian, who did most of the hard work. His efforts made my job
26
+ mostly a matter of playing around.
27
+
28
+
29
+ == Caveats
30
+
31
+ The database-writing portions of this code have not been extensively tested, and
32
+ there are almost certainly bugs which will cause data to be lost or
33
+ miswritten. You should make backups of changes you make periodically.
34
+
35
+ I would greatly appreciate feedback on any aspect of this software. Suggestions,
36
+ feature requests, questions, design critiques, and bug reports are most
37
+ welcome. Relevant patches are particularly helpful. I may be reached at
38
+ <ged@FaerieMUD.org>.
39
+
40
+
41
+ == Installation
42
+
43
+ If you use RubyGems, you can install via:
44
+
45
+ $ sudo gem install wordnet
46
+
47
+ You can also install as a site library via the Rakefile:
48
+
49
+ $ wget http://deveiate.org/code/wordnet-x.y.z.tar.gz
50
+ $ tar xzvf wordnet-x.y.z.tar.gz
51
+ $ cd wordnet-x.y.z
52
+ $ sudo rake install
53
+
54
+
55
+ == More Information
56
+
57
+ There is a project page for Ruby-WordNet which can be found at:
58
+ <http://deveiate.org/projects/Ruby-WordNet/>.
59
+
60
+ This library was developed as part of the FaerieMUD Project. For more
61
+ information about the FaerieMUD project see <http://www.FaerieMUD.org/>.
62
+
63
+ You may also check out the latest development source for this module (which may or
64
+ may not be different than the release) using Subversion from the following URL:
65
+
66
+ svn://deveiate.org/Ruby-WordNet/trunk
67
+
68
+
69
+ == Authors
70
+
71
+ * Michael Granger <ged@FaerieMUD.org>
72
+
73
+
74
+ == Legal
75
+
76
+ Ruby-WordNet is Open Source Software which is Copyright � 2001-2008 by The
77
+ FaerieMUD Consortium.
78
+
79
+ It is licensed under the modified BSD license. See the LICENSE file for details.
80
+
81
+ WordNet� is a registered trademark of Princeton University.
82
+
83
+ Lingua::Wordnet is code licensed under the following terms:
84
+
85
+ Lingua::Wordnet
86
+ Copyright 1999,2000,2001 by Dan Brian.
87
+
88
+ This program is free software; you can redistribute it and/or modify
89
+ it under the same terms as Perl itself.
90
+
91
+
92
+ $Id: README 95 2008-09-05 18:49:25Z deveiant $
93
+
data/Rakefile ADDED
@@ -0,0 +1,291 @@
1
+ #!rake
2
+ #
3
+ # WordNet rakefile
4
+ #
5
+ # Based on various other Rakefiles, especially one by Ben Bleything
6
+ #
7
+ # Copyright (c) 2008 The FaerieMUD Consortium
8
+ #
9
+ # Authors:
10
+ # * Michael Granger <ged@FaerieMUD.org>
11
+ #
12
+
13
+ BEGIN {
14
+ require 'pathname'
15
+ basedir = Pathname.new( __FILE__ ).dirname
16
+
17
+ libdir = basedir + "lib"
18
+ extdir = basedir + "ext"
19
+
20
+ $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
21
+ $LOAD_PATH.unshift( extdir.to_s ) unless $LOAD_PATH.include?( extdir.to_s )
22
+ }
23
+
24
+
25
+ require 'rbconfig'
26
+ require 'rubygems'
27
+ require 'rake'
28
+ require 'rake/rdoctask'
29
+ require 'rake/testtask'
30
+ require 'rake/packagetask'
31
+ require 'rake/clean'
32
+
33
+ $dryrun = false
34
+
35
+ ### Config constants
36
+ BASEDIR = Pathname.new( __FILE__ ).dirname.relative_path_from( Pathname.getwd )
37
+ BINDIR = BASEDIR + 'bin'
38
+ LIBDIR = BASEDIR + 'lib'
39
+ EXTDIR = BASEDIR + 'ext'
40
+ DOCSDIR = BASEDIR + 'docs'
41
+ PKGDIR = BASEDIR + 'pkg'
42
+
43
+ PROJECT_NAME = 'WordNet'
44
+ PKG_NAME = PROJECT_NAME.downcase
45
+ PKG_SUMMARY = 'a Ruby interface to the WordNet Lexical Database'
46
+ VERSION_FILE = LIBDIR + 'wordnet.rb'
47
+ PKG_VERSION = VERSION_FILE.read[ /VERSION = '(\d+\.\d+\.\d+)'/, 1 ]
48
+ PKG_FILE_NAME = "#{PKG_NAME.downcase}-#{PKG_VERSION}"
49
+ GEM_FILE_NAME = "#{PKG_FILE_NAME}.gem"
50
+
51
+ ARTIFACTS_DIR = Pathname.new( ENV['CC_BUILD_ARTIFACTS'] || 'artifacts' )
52
+
53
+ TEXT_FILES = %w( Rakefile ChangeLog README LICENSE ).collect {|filename| BASEDIR + filename }
54
+ BIN_FILES = Pathname.glob( BINDIR + '*' ).delete_if {|item| item =~ /\.svn/ }
55
+ LIB_FILES = Pathname.glob( LIBDIR + '**/*.rb' ).delete_if {|item| item =~ /\.svn/ }
56
+ EXT_FILES = Pathname.glob( EXTDIR + '**/*.{c,h,rb}' ).delete_if {|item| item =~ /\.svn/ }
57
+
58
+ SPECDIR = BASEDIR + 'spec'
59
+ SPECLIBDIR = SPECDIR + 'lib'
60
+ SPEC_FILES = Pathname.glob( SPECDIR + '**/*_spec.rb' ).delete_if {|item| item =~ /\.svn/ } +
61
+ Pathname.glob( SPECLIBDIR + '**/*.rb' ).delete_if {|item| item =~ /\.svn/ }
62
+
63
+ TESTDIR = BASEDIR + 'tests'
64
+ TEST_FILES = Pathname.glob( TESTDIR + '**/*.tests.rb' ).delete_if {|item| item =~ /\.svn/ }
65
+
66
+ RAKE_TASKDIR = BASEDIR + 'rake'
67
+ RAKE_TASKLIBS = Pathname.glob( RAKE_TASKDIR + '*.rb' )
68
+
69
+ LOCAL_RAKEFILE = BASEDIR + 'Rakefile.local'
70
+
71
+ EXTRA_PKGFILES = []
72
+ EXTRA_PKGFILES.concat Pathname.glob( BASEDIR + 'convertdb.rb' ).delete_if {|item| item =~ /\.svn/ }
73
+ EXTRA_PKGFILES.concat Pathname.glob( BASEDIR + 'utils.rb' ).delete_if {|item| item =~ /\.svn/ }
74
+ EXTRA_PKGFILES.concat Pathname.glob( BASEDIR + 'examples/*.rb' ).delete_if {|item| item =~ /\.svn/ }
75
+
76
+ RELEASE_FILES = TEXT_FILES +
77
+ SPEC_FILES +
78
+ TEST_FILES +
79
+ BIN_FILES +
80
+ LIB_FILES +
81
+ EXT_FILES +
82
+ RAKE_TASKLIBS +
83
+ EXTRA_PKGFILES
84
+
85
+ RELEASE_FILES << LOCAL_RAKEFILE if LOCAL_RAKEFILE.exist?
86
+
87
+ COVERAGE_MINIMUM = ENV['COVERAGE_MINIMUM'] ? Float( ENV['COVERAGE_MINIMUM'] ) : 85.0
88
+ RCOV_EXCLUDES = 'spec,tests,/Library/Ruby,/var/lib,/usr/local/lib'
89
+ RCOV_OPTS = [
90
+ '--exclude', RCOV_EXCLUDES,
91
+ '--xrefs',
92
+ '--save',
93
+ '--callsites',
94
+ #'--aggregate', 'coverage.data' # <- doesn't work as of 0.8.1.2.0
95
+ ]
96
+
97
+
98
+ # Subversion constants -- directory names for releases and tags
99
+ SVN_TRUNK_DIR = 'trunk'
100
+ SVN_RELEASES_DIR = 'releases'
101
+ SVN_BRANCHES_DIR = 'branches'
102
+ SVN_TAGS_DIR = 'tags'
103
+
104
+ SVN_DOTDIR = BASEDIR + '.svn'
105
+ SVN_ENTRIES = SVN_DOTDIR + 'entries'
106
+
107
+
108
+ ### Load some task libraries that need to be loaded early
109
+ require RAKE_TASKDIR + 'helpers.rb'
110
+ require RAKE_TASKDIR + 'svn.rb'
111
+ require RAKE_TASKDIR + 'verifytask.rb'
112
+
113
+ # Define some constants that depend on the 'svn' tasklib
114
+ PKG_BUILD = get_svn_rev( BASEDIR ) || 0
115
+ SNAPSHOT_PKG_NAME = "#{PKG_FILE_NAME}.#{PKG_BUILD}"
116
+ SNAPSHOT_GEM_NAME = "#{SNAPSHOT_PKG_NAME}.gem"
117
+
118
+ # Documentation constants
119
+ RDOCDIR = DOCSDIR + 'api'
120
+ RDOC_OPTIONS = [
121
+ '-w', '4',
122
+ '-SHN',
123
+ '-i', '.',
124
+ '-m', 'README',
125
+ '-W', 'http://deveiate.org/projects/Ruby-WordNet/browser/trunk/'
126
+ ]
127
+
128
+ # Release constants
129
+ SMTP_HOST = 'mail.faeriemud.org'
130
+ SMTP_PORT = 465 # SMTP + SSL
131
+
132
+ # Project constants
133
+ PROJECT_HOST = 'deveiate.org'
134
+ PROJECT_PUBDIR = "/usr/local/www/public/code"
135
+ PROJECT_DOCDIR = "#{PROJECT_PUBDIR}/#{PKG_NAME}"
136
+ PROJECT_SCPPUBURL = "#{PROJECT_HOST}:#{PROJECT_PUBDIR}"
137
+ PROJECT_SCPDOCURL = "#{PROJECT_HOST}:#{PROJECT_DOCDIR}"
138
+
139
+ # Rubyforge stuff
140
+ RUBYFORGE_GROUP = 'deveiate'
141
+ RUBYFORGE_PROJECT = 'wordnet'
142
+
143
+ # Gem dependencies: gemname => version
144
+ DEPENDENCIES = {
145
+ }
146
+
147
+ # Developer Gem dependencies: gemname => version
148
+ DEVELOPMENT_DEPENDENCIES = {
149
+ 'amatch' => '>= 0.2.3',
150
+ 'rake' => '>= 0.8.1',
151
+ 'rcodetools' => '>= 0.7.0.0',
152
+ 'rcov' => '>= 0',
153
+ 'RedCloth' => '>= 4.0.3',
154
+ 'rspec' => '>= 0',
155
+ 'rubyforge' => '>= 0',
156
+ 'termios' => '>= 0',
157
+ 'text-format' => '>= 1.0.0',
158
+ 'tmail' => '>= 1.2.3.1',
159
+ 'ultraviolet' => '>= 0.10.2',
160
+ 'libxml-ruby' => '>= 0.8.3',
161
+ }
162
+
163
+ # Non-gem requirements: packagename => version
164
+ REQUIREMENTS = {
165
+ 'bdb' => '>= 0.6.5',
166
+ }
167
+
168
+ # RubyGem specification
169
+ GEMSPEC = Gem::Specification.new do |gem|
170
+ gem.name = PKG_NAME.downcase
171
+ gem.version = PKG_VERSION
172
+
173
+ gem.summary = PKG_SUMMARY
174
+ gem.description = <<-EOD
175
+ A Ruby implementation of the WordNet lexical dictionary an online lexical reference system whose
176
+ design is inspired by current psycholinguistic theories of human lexical memory.
177
+ EOD
178
+
179
+ gem.authors = 'Michael Granger'
180
+ gem.email = 'ged@FaerieMUD.org'
181
+ gem.homepage = 'http://deveiate.org/projects/Ruby-WordNet'
182
+ gem.rubyforge_project = RUBYFORGE_PROJECT
183
+
184
+ gem.has_rdoc = true
185
+ gem.rdoc_options = RDOC_OPTIONS
186
+
187
+ gem.bindir = BINDIR.relative_path_from(BASEDIR).to_s
188
+
189
+
190
+ gem.files = RELEASE_FILES.
191
+ collect {|f| f.relative_path_from(BASEDIR).to_s }
192
+ gem.test_files = SPEC_FILES.
193
+ collect {|f| f.relative_path_from(BASEDIR).to_s }
194
+
195
+ DEPENDENCIES.each do |name, version|
196
+ version = '>= 0' if version.length.zero?
197
+ gem.add_runtime_dependency( name, version )
198
+ end
199
+
200
+ DEVELOPMENT_DEPENDENCIES.each do |name, version|
201
+ version = '>= 0' if version.length.zero?
202
+ gem.add_development_dependency( name, version )
203
+ end
204
+
205
+ REQUIREMENTS.each do |name, version|
206
+ gem.requirements << [ name, version ].compact.join(' ')
207
+ end
208
+ end
209
+
210
+ # Manual-generation config
211
+ MANUALDIR = DOCSDIR + 'manual'
212
+
213
+ $trace = Rake.application.options.trace ? true : false
214
+ $dryrun = Rake.application.options.dryrun ? true : false
215
+
216
+
217
+ # Load any remaining task libraries
218
+ RAKE_TASKLIBS.each do |tasklib|
219
+ next if tasklib =~ %r{/(helpers|svn|verifytask)\.rb$}
220
+ begin
221
+ require tasklib
222
+ rescue ScriptError => err
223
+ fail "Task library '%s' failed to load: %s: %s" %
224
+ [ tasklib, err.class.name, err.message ]
225
+ trace "Backtrace: \n " + err.backtrace.join( "\n " )
226
+ rescue => err
227
+ log "Task library '%s' failed to load: %s: %s. Some tasks may not be available." %
228
+ [ tasklib, err.class.name, err.message ]
229
+ trace "Backtrace: \n " + err.backtrace.join( "\n " )
230
+ end
231
+ end
232
+
233
+ # Load any project-specific rules defined in 'Rakefile.local' if it exists
234
+ import LOCAL_RAKEFILE if LOCAL_RAKEFILE.exist?
235
+
236
+
237
+ #####################################################################
238
+ ### T A S K S
239
+ #####################################################################
240
+
241
+ ### Default task
242
+ task :default => [:clean, :local, :spec, :rdoc, :package]
243
+
244
+ ### Task the local Rakefile can append to -- no-op by default
245
+ task :local
246
+
247
+
248
+ ### Task: clean
249
+ CLEAN.include 'coverage'
250
+ CLOBBER.include 'artifacts', 'coverage.info', PKGDIR
251
+
252
+ # Target to hinge on ChangeLog updates
253
+ file SVN_ENTRIES
254
+
255
+ ### Task: changelog
256
+ file 'ChangeLog' => SVN_ENTRIES.to_s do |task|
257
+ log "Updating #{task.name}"
258
+
259
+ changelog = make_svn_changelog()
260
+ File.open( task.name, 'w' ) do |fh|
261
+ fh.print( changelog )
262
+ end
263
+ end
264
+
265
+
266
+ ### Task: cruise (Cruisecontrol task)
267
+ desc "Cruisecontrol build"
268
+ task :cruise => [:clean, :spec, :package] do |task|
269
+ raise "Artifacts dir not set." if ARTIFACTS_DIR.to_s.empty?
270
+ artifact_dir = ARTIFACTS_DIR.cleanpath
271
+ artifact_dir.mkpath
272
+
273
+ coverage = BASEDIR + 'coverage'
274
+ if coverage.exist? && coverage.directory?
275
+ $stderr.puts "Copying coverage stats..."
276
+ FileUtils.cp_r( 'coverage', artifact_dir )
277
+ end
278
+
279
+ $stderr.puts "Copying packages..."
280
+ FileUtils.cp_r( FileList['pkg/*'].to_a, artifact_dir )
281
+ end
282
+
283
+
284
+ desc "Update the build system to the latest version"
285
+ task :update_build do
286
+ log "Updating the build system"
287
+ sh 'svn', 'up', RAKE_TASKDIR
288
+ log "Updating the Rakefile"
289
+ sh 'rake', '-f', RAKE_TASKDIR + 'Metarakefile'
290
+ end
291
+
data/Rakefile.local ADDED
@@ -0,0 +1,46 @@
1
+ #!rake
2
+ #
3
+ # Project-local tasks for Ruby-WordNet
4
+ # $Id: Rakefile.local 95 2008-09-05 18:49:25Z deveiant $
5
+ #
6
+ # Authors:
7
+ # * Michael Granger <ged@FaerieMUD.org>
8
+ #
9
+
10
+ unless defined?( BASEDIR )
11
+ fail "This is meant to be loaded from the main Rakefile, not run directly."
12
+ end
13
+
14
+
15
+ require 'wordnet'
16
+ require 'rake'
17
+
18
+ CONVERT_UTIL = BASEDIR + 'convertdb.rb'
19
+ DATA_BUILD_DIR = BASEDIR + File.basename( WordNet::Lexicon::DEFAULT_DB_ENV )
20
+ DATA_DATABASE_FILE = DATA_BUILD_DIR + 'data'
21
+
22
+
23
+ ### Tasks
24
+
25
+ # Add 'convert' to the default task, and the testing tasks
26
+ Rake::Task[:default].prerequisites << :convert
27
+ Rake::Task[:spec].prerequisites << :convert
28
+
29
+ ### Task: convert
30
+ desc "Convert WordNet dict files to a database"
31
+ task :convert => DATA_DATABASE_FILE
32
+
33
+ # Conversion utility
34
+ file CONVERT_UTIL.to_s
35
+
36
+ # Build directory for the database files
37
+ directory DATA_BUILD_DIR.to_s
38
+ CLOBBER.include( DATA_BUILD_DIR.to_s )
39
+
40
+ # BerkeleyDB main database file
41
+ file DATA_DATABASE_FILE.to_s
42
+ task DATA_DATABASE_FILE.to_s => CONVERT_UTIL do
43
+ load CONVERT_UTIL
44
+ WordNetConverter.new( DATA_BUILD_DIR ).convertdb
45
+ end
46
+