wordnet 1.0.0.pre.127 → 1.0.0.pre.134

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -1,3 +1,4 @@
1
+ ChangeLog
1
2
  History.rdoc
2
3
  LICENSE
3
4
  Manifest.txt
@@ -20,14 +21,12 @@ lib/wordnet.rb
20
21
  lib/wordnet/constants.rb
21
22
  lib/wordnet/lexicallink.rb
22
23
  lib/wordnet/lexicon.rb
23
- lib/wordnet/mixins.rb
24
24
  lib/wordnet/model.rb
25
25
  lib/wordnet/morph.rb
26
26
  lib/wordnet/semanticlink.rb
27
27
  lib/wordnet/sense.rb
28
28
  lib/wordnet/sumoterm.rb
29
29
  lib/wordnet/synset.rb
30
- lib/wordnet/utils.rb
31
30
  lib/wordnet/word.rb
32
31
  spec/lib/helpers.rb
33
32
  spec/linguawordnet.tests.rb
data/README.rdoc CHANGED
@@ -31,7 +31,7 @@ TO-DO: More details and better writing later.
31
31
 
32
32
  == License
33
33
 
34
- Copyright (c) 2010-2011, The FaerieMUD Consortium
34
+ Copyright (c) 2002-2012, The FaerieMUD Consortium
35
35
  All rights reserved.
36
36
 
37
37
  Redistribution and use in source and binary forms, with or without
data/Rakefile CHANGED
@@ -24,16 +24,18 @@ hoespec = Hoe.spec( 'wordnet' ) do
24
24
  self.readme_file = 'README.rdoc'
25
25
  self.history_file = 'History.rdoc'
26
26
  self.extra_rdoc_files = FileList[ '*.rdoc' ]
27
+ self.spec_extras[:rdoc_options] = ['-f', 'fivefish', '-t', 'Ruby WordNet']
27
28
 
28
29
  self.developer 'Michael Granger', 'ged@FaerieMUD.org'
29
30
 
30
- self.dependency 'sequel', '~> 3.29'
31
- self.dependency 'sqlite3', '~> 1.3', :developer
32
- self.dependency 'rspec', '~> 2.7', :developer
31
+ self.dependency 'sequel', '~> 3.38'
32
+ self.dependency 'loggability', '~> 0.5'
33
+ self.dependency 'sqlite3', '~> 1.3', :developer
34
+ self.dependency 'rspec', '~> 2.7', :developer
33
35
 
34
36
  self.spec_extras[:licenses] = ["BSD"]
35
37
  self.spec_extras[:post_install_message] = %{
36
- If you don't already have a WordNet database installed somewhere,
38
+ If you don't already have a WordNet database installed somewhere,
37
39
  you'll need to either download and install one from:
38
40
 
39
41
  http://wnsql.sourceforge.net/
@@ -46,6 +48,9 @@ hoespec = Hoe.spec( 'wordnet' ) do
46
48
  self.require_ruby_version( '>=1.9.2' )
47
49
 
48
50
  self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags )
51
+ self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
52
+
53
+ self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
49
54
  end
50
55
 
51
56
  ENV['VERSION'] ||= hoespec.spec.version.to_s
data/lib/wordnet.rb CHANGED
@@ -1,13 +1,18 @@
1
1
  #!/usr/bin/env ruby
2
2
  #encoding: utf-8
3
3
 
4
- require 'logger'
4
+ require 'loggability'
5
5
  require 'sequel'
6
6
 
7
7
  # This is a Ruby interface to the WordNet® lexical database. It uses the WordNet-SQL
8
8
  # project's databases instead of reading from the canonical flatfiles for speed and
9
9
  # easy modification.
10
10
  module WordNet
11
+ extend Loggability
12
+
13
+ # Loggability API -- Set up a logger for WordNet classes
14
+ log_as :wordnet
15
+
11
16
 
12
17
  # Release version
13
18
  VERSION = '1.0.0'
@@ -16,9 +21,8 @@ module WordNet
16
21
  REVISION = %q$Revision: $
17
22
 
18
23
  # Abort if not >=1.9.2
19
- vvec = lambda {|version| version.split('.').collect {|v| v.to_i }.pack('N*') }
20
24
  abort "This version of WordNet requires Ruby 1.9.2 or greater." unless
21
- vvec[RUBY_VERSION] >= vvec['1.9.2']
25
+ RUBY_VERSION >= '1.9.2'
22
26
 
23
27
 
24
28
  ### Lexicon exception - something has gone wrong in the internals of the
@@ -32,50 +36,6 @@ module WordNet
32
36
 
33
37
  require 'wordnet/constants'
34
38
  include WordNet::Constants
35
- require 'wordnet/utils'
36
-
37
- #
38
- # Logging
39
- #
40
-
41
- @default_logger = Logger.new( $stderr )
42
- @default_logger.level = $DEBUG ? Logger::DEBUG : Logger::WARN
43
-
44
- @default_log_formatter = WordNet::LogFormatter.new( @default_logger )
45
- @default_logger.formatter = @default_log_formatter
46
-
47
- @logger = @default_logger
48
-
49
- class << self
50
- # @return [Logger::Formatter] the log formatter that will be used when the logging
51
- # subsystem is reset
52
- attr_accessor :default_log_formatter
53
-
54
- # @return [Logger] the logger that will be used when the logging subsystem is reset
55
- attr_accessor :default_logger
56
-
57
- # @return [Logger] the logger that's currently in effect
58
- attr_accessor :logger
59
- alias_method :log, :logger
60
- alias_method :log=, :logger=
61
- end
62
-
63
-
64
- ### Reset the global logger object to the default
65
- ### @return [void]
66
- def self::reset_logger
67
- self.logger = self.default_logger
68
- self.logger.level = Logger::WARN
69
- self.logger.formatter = self.default_log_formatter
70
- end
71
-
72
-
73
- ### Returns +true+ if the global logger has not been set to something other than
74
- ### the default one.
75
- def self::using_default_logger?
76
- return self.logger == self.default_logger
77
- end
78
-
79
39
 
80
40
  ### Get the WordNet version.
81
41
  ### @return [String] the library's version
@@ -164,11 +164,11 @@ module WordNet::Constants
164
164
 
165
165
  # Record-part delimiter
166
166
  DELIM = '||'
167
- DELIM_RE = Regexp::new( Regexp::quote(DELIM) )
167
+ DELIM_RE = Regexp.new( Regexp::quote(DELIM) )
168
168
 
169
169
  # Record-subpart delimiter
170
170
  SUB_DELIM = '|'
171
- SUB_DELIM_RE = Regexp::new( Regexp::quote(SUB_DELIM) )
171
+ SUB_DELIM_RE = Regexp.new( Regexp::quote(SUB_DELIM) )
172
172
 
173
173
  # Lexicographer file index -- from lexnames(5WN)
174
174
  LEXFILES = [
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  require 'pathname'
4
+ require 'loggability'
4
5
  require 'rubygems'
5
6
 
6
7
  require 'wordnet' unless defined?( WordNet )
7
8
  require 'wordnet/constants'
8
- require 'wordnet/mixins'
9
9
  require 'wordnet/synset'
10
10
  require 'wordnet/word'
11
11
 
@@ -13,8 +13,11 @@ require 'wordnet/word'
13
13
  # WordNet lexicon class - abstracts access to the WordNet lexical
14
14
  # database, and provides factory methods for looking up words and synsets.
15
15
  class WordNet::Lexicon
16
- include WordNet::Constants,
17
- WordNet::Loggable
16
+ extend Loggability
17
+ include WordNet::Constants
18
+
19
+ # Loggability API -- log to the WordNet module's logger
20
+ log_to :wordnet
18
21
 
19
22
  # class LogTracer
20
23
  # def method_missing( sym, msg, &block )
@@ -27,25 +30,33 @@ class WordNet::Lexicon
27
30
 
28
31
 
29
32
  # Add the logger device to the default options after it's been loaded
30
- WordNet::DEFAULT_DB_OPTIONS.merge!( :logger => [WordNet.logger] )
33
+ WordNet::DEFAULT_DB_OPTIONS.merge!( :logger => [Loggability[WordNet]] )
31
34
  # WordNet::DEFAULT_DB_OPTIONS.merge!( :logger => [LogTracer.new] )
32
35
 
33
36
 
34
37
  ### Get the Sequel URI of the default database, if it's installed.
35
38
  def self::default_db_uri
36
- WordNet.log.debug "Fetching the default db URI"
39
+ self.log.debug "Fetching the default db URI"
40
+
41
+ # Try to load the default database gem, ignoring it if it's not installed.
42
+ begin
43
+ gem 'wordnet-defaultdb'
44
+ rescue Gem::LoadError
45
+ end
37
46
 
47
+ # Now try the gem datadir first, and fall back to a local installation of the
48
+ # default db
38
49
  datadir = nil
39
50
  if Gem.datadir( 'wordnet-defaultdb' )
40
51
  datadir = Pathname( Gem.datadir('wordnet-defaultdb') )
41
52
  else
42
- WordNet.log.warn " no defaultdb gem; looking for the development database"
53
+ self.log.warn " no defaultdb gem; looking for the development database"
43
54
  datadir = Pathname( __FILE__ ).dirname.parent.parent +
44
55
  'wordnet-defaultdb/data/wordnet-defaultdb'
45
56
  end
46
57
 
47
58
  dbfile = datadir + 'wordnet30.sqlite'
48
- WordNet.log.debug " dbfile is: %s" % [ dbfile ]
59
+ self.log.debug " dbfile is: %s" % [ dbfile ]
49
60
 
50
61
  if dbfile.exist?
51
62
  return "sqlite:#{dbfile}"
data/lib/wordnet/model.rb CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
+ require 'loggability'
3
4
  require 'sequel'
4
5
 
5
6
  # Use a mock database until the real one is provided by the user
6
7
  Sequel::Model.db = Sequel.mock if Sequel::DATABASES.empty?
7
8
 
8
9
  require 'wordnet' unless defined?( WordNet )
9
- require 'wordnet/mixins'
10
10
 
11
11
  module WordNet
12
12
 
@@ -18,8 +18,12 @@ module WordNet
18
18
  # 'validation_helpers', 'schema', and 'subclasses' Sequel plugins.
19
19
  #
20
20
  class Model < Sequel::Model
21
- include WordNet::Loggable
21
+ extend Loggability
22
22
 
23
+ # Loggability API -- log to the WordNet module's logger
24
+ log_to :wordnet
25
+
26
+ # Sequel plugins
23
27
  plugin :validation_helpers
24
28
  plugin :schema
25
29
  plugin :subclasses
@@ -46,7 +50,7 @@ module WordNet
46
50
  end
47
51
 
48
52
  self.descendents.each do |subclass|
49
- WordNet.log.info "Resetting database connection for: %p to: %p" % [ subclass, newdb ]
53
+ self.log.info "Resetting database connection for: %p to: %p" % [ subclass, newdb ]
50
54
  subclass.db = newdb
51
55
  end
52
56
  end
data/lib/wordnet/morph.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  require 'wordnet' unless defined?( WordNet )
4
- require 'wordnet/mixins'
5
4
  require 'wordnet/model'
6
5
 
7
6
  # WordNet morph model class
data/lib/wordnet/sense.rb CHANGED
@@ -24,7 +24,7 @@ class WordNet::Sense < WordNet::Model( :senses )
24
24
  def self::lexical_link( type, typekey=nil )
25
25
  typekey ||= type.to_s.chomp( 's' ).to_sym
26
26
 
27
- WordNet.log.debug "Generating a %p method for %p links" % [ type, typekey ]
27
+ self.log.debug "Generating a %p method for %p links" % [ type, typekey ]
28
28
 
29
29
  method_body = Proc.new do
30
30
  linkinfo = WordNet::Synset.linktype_names[ typekey ] or
@@ -32,7 +32,7 @@ class WordNet::Sense < WordNet::Model( :senses )
32
32
  ssids = self.lexlinks_dataset.filter( :linkid => linkinfo[:id] ).select( :synset2id )
33
33
  self.class.filter( :synsetid => ssids )
34
34
  end
35
- WordNet.log.debug " method body is: %p" % [ method_body ]
35
+ self.log.debug " method body is: %p" % [ method_body ]
36
36
 
37
37
  define_method( type, &method_body )
38
38
  end
@@ -153,6 +153,8 @@ class WordNet::Synset < WordNet::Model( :synsets )
153
153
  def_dataset_method( :adjective_satellites ) { filter(pos: 's') }
154
154
 
155
155
 
156
+ # :section:
157
+
156
158
  ### Overridden to reset any lookup tables that may have been loaded from the previous
157
159
  ### database.
158
160
  def self::db=( newdb )
@@ -225,10 +227,17 @@ class WordNet::Synset < WordNet::Model( :synsets )
225
227
  end
226
228
 
227
229
 
230
+ ##
231
+ # :singleton-method: semantic_link_methods
232
+ # An Array of semantic link methods
233
+ class << self; attr_reader :semantic_link_methods ; end
234
+ @semantic_link_methods = []
235
+
236
+
228
237
  ### Generate methods that will return Synsets related by the given semantic pointer
229
238
  ### +type+.
230
239
  def self::semantic_link( type )
231
- WordNet.log.debug "Generating a %p method" % [ type ]
240
+ self.log.debug "Generating a %p method" % [ type ]
232
241
 
233
242
  ds_method_body = Proc.new do
234
243
  self.semanticlink_dataset( type )
@@ -239,6 +248,8 @@ class WordNet::Synset < WordNet::Model( :synsets )
239
248
  self.semanticlink_dataset( type ).all
240
249
  end
241
250
  define_method( type, &ss_method_body )
251
+
252
+ self.semantic_link_methods << type.to_sym
242
253
  end
243
254
 
244
255
 
data/lib/wordnet/word.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/ruby
2
2
 
3
3
  require 'wordnet' unless defined?( WordNet )
4
- require 'wordnet/mixins'
5
4
  require 'wordnet/model'
6
5
 
7
6
  # WordNet word model class
data/spec/lib/helpers.rb CHANGED
@@ -12,41 +12,13 @@ BEGIN {
12
12
  }
13
13
 
14
14
  require 'rspec'
15
+ require 'loggability/spechelpers'
15
16
  require 'wordnet'
16
17
 
17
18
 
18
19
  ### RSpec helper functions.
19
20
  module WordNet::SpecHelpers
20
21
 
21
- # A logger that logs to an array.
22
- class ArrayLogger
23
- ### Create a new ArrayLogger that will append content to +array+.
24
- def initialize( array )
25
- @array = array
26
- end
27
-
28
- ### Write the specified +message+ to the array.
29
- def write( message )
30
- @array << message
31
- end
32
-
33
- ### No-op -- this is here just so Logger doesn't complain
34
- def close; end
35
-
36
- end # class ArrayLogger
37
-
38
-
39
- unless defined?( LEVEL )
40
- LEVEL = {
41
- :debug => Logger::DEBUG,
42
- :info => Logger::INFO,
43
- :warn => Logger::WARN,
44
- :error => Logger::ERROR,
45
- :fatal => Logger::FATAL,
46
- }
47
- end
48
-
49
-
50
22
  ###############
51
23
  module_function
52
24
  ###############
@@ -57,35 +29,6 @@ module WordNet::SpecHelpers
57
29
  end
58
30
 
59
31
 
60
- ### Reset the logging subsystem to its default state.
61
- def reset_logging
62
- WordNet.reset_logger
63
- end
64
-
65
-
66
- ### Alter the output of the default log formatter to be pretty in SpecMate output
67
- def setup_logging( level=Logger::FATAL )
68
-
69
- # Turn symbol-style level config into Logger's expected Fixnum level
70
- if LEVEL.key?( level )
71
- level = LEVEL[ level ]
72
- end
73
-
74
- logger = Logger.new( $stderr )
75
- WordNet.logger = logger
76
- WordNet.logger.level = level
77
-
78
- # Only do this when executing from a spec in TextMate
79
- if ENV['HTML_LOGGING'] || (ENV['TM_FILENAME'] && ENV['TM_FILENAME'] =~ /_spec\.rb/)
80
- Thread.current['logger-output'] = []
81
- logdevice = ArrayLogger.new( Thread.current['logger-output'] )
82
- WordNet.logger = Logger.new( logdevice )
83
- # WordNet.logger.level = level
84
- WordNet.logger.formatter = WordNet::HtmlLogFormatter.new( logger )
85
- end
86
- end
87
-
88
-
89
32
  ### Make a WordNet::Directory that will use the given +conn+ object as its
90
33
  ### LDAP connection. Also pre-loads the schema object and fixtures some other
91
34
  ### external data.
@@ -105,6 +48,7 @@ end
105
48
  RSpec.configure do |c|
106
49
  c.mock_with :rspec
107
50
  c.include( WordNet::SpecHelpers )
51
+ c.include( Loggability::SpecHelpers )
108
52
 
109
53
  c.treat_symbols_as_metadata_keys_with_true_values = true
110
54
 
data/spec/wordnet_spec.rb CHANGED
@@ -30,14 +30,6 @@ describe WordNet do
30
30
  reset_logging()
31
31
  end
32
32
 
33
- it "should know if its default logger is replaced" do
34
- WordNet.reset_logger
35
- WordNet.should be_using_default_logger
36
- WordNet.logger = Logger.new( $stderr )
37
- WordNet.should_not be_using_default_logger
38
- end
39
-
40
-
41
33
  it "returns a version string if asked" do
42
34
  WordNet.version_string.should =~ /\w+ [\d.]+/
43
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordnet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.127
4
+ version: 1.0.0.pre.134
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -36,7 +36,7 @@ cert_chain:
36
36
  YUhDS0xaZFNLai9SSHVUT3QrZ2JsUmV4OEZBaDhOZUEKY21saFhlNDZwWk5K
37
37
  Z1dLYnhaYWg4NWpJang5NWhSOHZPSStOQU01aUg5a09xSzEzRHJ4YWNUS1Bo
38
38
  cWo1UGp3RgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
39
- date: 2012-05-01 00:00:00.000000000 Z
39
+ date: 2012-08-06 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sequel
@@ -45,7 +45,7 @@ dependencies:
45
45
  requirements:
46
46
  - - ~>
47
47
  - !ruby/object:Gem::Version
48
- version: '3.29'
48
+ version: '3.38'
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
@@ -53,7 +53,23 @@ dependencies:
53
53
  requirements:
54
54
  - - ~>
55
55
  - !ruby/object:Gem::Version
56
- version: '3.29'
56
+ version: '3.38'
57
+ - !ruby/object:Gem::Dependency
58
+ name: loggability
59
+ requirement: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ~>
63
+ - !ruby/object:Gem::Version
64
+ version: '0.5'
65
+ type: :runtime
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ~>
71
+ - !ruby/object:Gem::Version
72
+ version: '0.5'
57
73
  - !ruby/object:Gem::Dependency
58
74
  name: hoe-mercurial
59
75
  requirement: !ruby/object:Gem::Requirement
@@ -77,7 +93,7 @@ dependencies:
77
93
  requirements:
78
94
  - - ~>
79
95
  - !ruby/object:Gem::Version
80
- version: 0.0.1
96
+ version: 0.1.0
81
97
  type: :development
82
98
  prerelease: false
83
99
  version_requirements: !ruby/object:Gem::Requirement
@@ -85,7 +101,7 @@ dependencies:
85
101
  requirements:
86
102
  - - ~>
87
103
  - !ruby/object:Gem::Version
88
- version: 0.0.1
104
+ version: 0.1.0
89
105
  - !ruby/object:Gem::Dependency
90
106
  name: rdoc
91
107
  requirement: !ruby/object:Gem::Requirement
@@ -182,6 +198,7 @@ extra_rdoc_files:
182
198
  - README.rdoc
183
199
  - WordNet30-license.txt
184
200
  files:
201
+ - ChangeLog
185
202
  - History.rdoc
186
203
  - LICENSE
187
204
  - Manifest.txt
@@ -204,14 +221,12 @@ files:
204
221
  - lib/wordnet/constants.rb
205
222
  - lib/wordnet/lexicallink.rb
206
223
  - lib/wordnet/lexicon.rb
207
- - lib/wordnet/mixins.rb
208
224
  - lib/wordnet/model.rb
209
225
  - lib/wordnet/morph.rb
210
226
  - lib/wordnet/semanticlink.rb
211
227
  - lib/wordnet/sense.rb
212
228
  - lib/wordnet/sumoterm.rb
213
229
  - lib/wordnet/synset.rb
214
- - lib/wordnet/utils.rb
215
230
  - lib/wordnet/word.rb
216
231
  - spec/lib/helpers.rb
217
232
  - spec/linguawordnet.tests.rb
@@ -226,12 +241,14 @@ homepage: http://deveiate.org/projects/Ruby-WordNet
226
241
  licenses:
227
242
  - BSD
228
243
  post_install_message: ! "\nIf you don't already have a WordNet database installed
229
- somewhere, \nyou'll need to either download and install one from:\n\n http://wnsql.sourceforge.net/\n\nor
244
+ somewhere,\nyou'll need to either download and install one from:\n\n http://wnsql.sourceforge.net/\n\nor
230
245
  just install the 'wordnet-defaultdb' gem, which will install\nthe SQLite version
231
246
  for you.\n\n"
232
247
  rdoc_options:
233
- - --main
234
- - README.rdoc
248
+ - -f
249
+ - fivefish
250
+ - -t
251
+ - Ruby WordNet
235
252
  require_paths:
236
253
  - lib
237
254
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -248,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
265
  version: '0'
249
266
  requirements: []
250
267
  rubyforge_project: wordnet
251
- rubygems_version: 1.8.21
268
+ rubygems_version: 1.8.24
252
269
  signing_key:
253
270
  specification_version: 3
254
271
  summary: This library is a Ruby interface to WordNet®