wordnet 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gems +5 -0
  5. data/.ruby-gemset +1 -0
  6. data/.ruby-version +1 -0
  7. data/.simplecov +8 -0
  8. data/Gemfile +2 -0
  9. data/History.rdoc +7 -0
  10. data/Manifest.txt +11 -12
  11. data/README.md +1 -0
  12. data/Rakefile +44 -25
  13. data/certs/ged.pem +26 -0
  14. data/examples/gcs.rb +24 -34
  15. data/examples/hypernym_tree.rb +34 -0
  16. data/lib/wordnet.rb +4 -4
  17. data/lib/wordnet/constants.rb +2 -1
  18. data/lib/wordnet/lexicallink.rb +2 -1
  19. data/lib/wordnet/lexicon.rb +6 -5
  20. data/lib/wordnet/model.rb +2 -1
  21. data/lib/wordnet/morph.rb +2 -1
  22. data/lib/wordnet/semanticlink.rb +2 -1
  23. data/lib/wordnet/sense.rb +48 -4
  24. data/lib/wordnet/sumoterm.rb +3 -2
  25. data/lib/wordnet/synset.rb +12 -10
  26. data/lib/wordnet/word.rb +21 -20
  27. data/spec/helpers.rb +43 -0
  28. data/spec/wordnet/lexicon_spec.rb +44 -61
  29. data/spec/wordnet/model_spec.rb +5 -37
  30. data/spec/wordnet/semanticlink_spec.rb +6 -26
  31. data/spec/wordnet/sense_spec.rb +80 -0
  32. data/spec/wordnet/synset_spec.rb +33 -47
  33. data/spec/wordnet/word_spec.rb +22 -42
  34. data/spec/wordnet_spec.rb +4 -23
  35. data/wordnet.gemspec +63 -0
  36. metadata +110 -113
  37. metadata.gz.sig +0 -0
  38. data/.gemtest +0 -0
  39. data/examples/add-laced-boots.rb +0 -35
  40. data/examples/clothes-with-collars.rb +0 -42
  41. data/examples/clothesWithTongues.rb +0 -28
  42. data/examples/distance.rb +0 -37
  43. data/examples/domainTree.rb +0 -27
  44. data/examples/holonymTree.rb +0 -27
  45. data/examples/hypernymTree.rb +0 -28
  46. data/examples/hyponymTree.rb +0 -28
  47. data/examples/memberTree.rb +0 -27
  48. data/examples/meronymTree.rb +0 -29
  49. data/spec/lib/helpers.rb +0 -80
  50. data/spec/linguawordnet.tests.rb +0 -38
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ad96c50badb95731cea04d9413faee469842b80b9831ccd17fbe60206069cb9d
4
+ data.tar.gz: f8d045d5d3d4d4ece365c66cca1b8a630b6133b7164d6000f016b7eae74b8812
5
+ SHA512:
6
+ metadata.gz: c518543f3492cb5365c2b21ee775213bbfb8aab36f6dcf5294123453a45b8c819559d0f2a88b0245874775c044fb13d494382a9a18d8ac6f99e1c09f8c619e85
7
+ data.tar.gz: d2de124e23a91f9f1cac09d0c150a7336649fbaf5b8ef45141838c5a6a9b37b6a70f31da99b7bd27b97e88823e36558ce6abe7ae14b102e621835576c4330944
Binary file
data.tar.gz.sig CHANGED
Binary file
data/.gems ADDED
@@ -0,0 +1,5 @@
1
+ hoe-deveiate -v0.8.0
2
+ sequel -v4.38.0
3
+ sqlite3 -v1.3.11
4
+ loggability -v0.11.0
5
+ simplecov -v0.12.0
@@ -0,0 +1 @@
1
+ wordnet
@@ -0,0 +1 @@
1
+ 2.3
@@ -0,0 +1,8 @@
1
+ # Simplecov config
2
+
3
+ SimpleCov.start do
4
+ add_filter 'spec'
5
+ add_group "Needing tests" do |file|
6
+ file.covered_percent < 90
7
+ end
8
+ end
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
@@ -1,3 +1,10 @@
1
+ == v1.0.1 [2016-09-18] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ - Finish up and fix WordNet::Sense
4
+ - Add Wordnet::Synset#wordlist
5
+ - Documentation fixes, fixes for newer Ruby versions
6
+
7
+
1
8
  == v1.0.0 [2012-08-22] Michael Granger <ged@FaerieMUD.org>
2
9
 
3
10
  Converted to use Sequel and wnsql.
@@ -1,22 +1,20 @@
1
+ .gems
2
+ .ruby-gemset
3
+ .ruby-version
4
+ .simplecov
1
5
  ChangeLog
6
+ Gemfile
2
7
  History.rdoc
3
8
  LICENSE
4
9
  Manifest.txt
10
+ README.md
5
11
  README.rdoc
6
12
  Rakefile
7
13
  TODO
8
14
  WordNet30-license.txt
9
- examples/add-laced-boots.rb
10
- examples/clothes-with-collars.rb
11
- examples/clothesWithTongues.rb
12
- examples/distance.rb
13
- examples/domainTree.rb
15
+ certs/ged.pem
14
16
  examples/gcs.rb
15
- examples/holonymTree.rb
16
- examples/hypernymTree.rb
17
- examples/hyponymTree.rb
18
- examples/memberTree.rb
19
- examples/meronymTree.rb
17
+ examples/hypernym_tree.rb
20
18
  lib/wordnet.rb
21
19
  lib/wordnet/constants.rb
22
20
  lib/wordnet/lexicallink.rb
@@ -28,11 +26,12 @@ lib/wordnet/sense.rb
28
26
  lib/wordnet/sumoterm.rb
29
27
  lib/wordnet/synset.rb
30
28
  lib/wordnet/word.rb
31
- spec/lib/helpers.rb
32
- spec/linguawordnet.tests.rb
29
+ spec/helpers.rb
33
30
  spec/wordnet/lexicon_spec.rb
34
31
  spec/wordnet/model_spec.rb
35
32
  spec/wordnet/semanticlink_spec.rb
33
+ spec/wordnet/sense_spec.rb
36
34
  spec/wordnet/synset_spec.rb
37
35
  spec/wordnet/word_spec.rb
38
36
  spec/wordnet_spec.rb
37
+ wordnet.gemspec
@@ -0,0 +1 @@
1
+ The README is in RDoc format, which Bitbucket doesn't support; [see the source](https://bitbucket.org/ged/ruby-wordnet/src/3db62d5ed69878e8e7c36795d3379291db0402d6/README.rdoc?at=default).
data/Rakefile CHANGED
@@ -10,6 +10,8 @@ rescue LoadError => err
10
10
  abort "This Rakefile requires hoe (gem install hoe)"
11
11
  end
12
12
 
13
+ GEMSPEC = 'wordnet.gemspec'
14
+
13
15
  Hoe.plugin :mercurial
14
16
  Hoe.plugin :signing
15
17
 
@@ -20,21 +22,20 @@ LIBDIR = BASEDIR + 'lib'
20
22
  DATADIR = BASEDIR + 'data'
21
23
 
22
24
  hoespec = Hoe.spec( 'wordnet' ) do
23
- self.name = 'wordnet'
24
25
  self.readme_file = 'README.rdoc'
25
26
  self.history_file = 'History.rdoc'
26
27
  self.extra_rdoc_files = FileList[ '*.rdoc' ]
27
- self.spec_extras[:rdoc_options] = ['-f', 'fivefish', '-t', 'Ruby WordNet']
28
+ self.license 'BSD-3-Clause'
28
29
 
29
30
  self.developer 'Michael Granger', 'ged@FaerieMUD.org'
30
31
 
31
- self.dependency 'sequel', '~> 3.38'
32
- self.dependency 'loggability', '~> 0.5'
32
+ self.dependency 'sequel', '~> 4.38'
33
+ self.dependency 'loggability', '~> 0.11'
34
+
33
35
  self.dependency 'sqlite3', '~> 1.3', :developer
34
- self.dependency 'rspec', '~> 2.7', :developer
35
- self.dependency 'simplecov', '~> 0.6', :developer
36
+ self.dependency 'rspec', '~> 3.5', :developer
37
+ self.dependency 'simplecov', '~> 0.12', :developer
36
38
 
37
- self.spec_extras[:licenses] = ["BSD"]
38
39
  self.spec_extras[:post_install_message] = %{
39
40
  If you don't already have a WordNet database installed somewhere,
40
41
  you'll need to either download and install one from:
@@ -46,38 +47,56 @@ hoespec = Hoe.spec( 'wordnet' ) do
46
47
 
47
48
  }.gsub( /^\t/, '' )
48
49
 
49
- self.require_ruby_version( '>=1.9.2' )
50
+ self.require_ruby_version( '>=2.2.0' )
50
51
 
51
52
  self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags )
52
53
  self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
53
54
 
54
- self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
55
+ self.rdoc_locations << "deveiate:/usr/local/www/public/code/ruby-#{remote_rdoc_dir}"
55
56
  end
56
57
 
57
58
  ENV['VERSION'] ||= hoespec.spec.version.to_s
58
59
 
59
- task 'hg:precheckin' => [ :check_history, :spec ]
60
-
61
- ### Make the ChangeLog update if the repo has changed since it was last built
62
- file '.hg/branch'
63
- file 'ChangeLog' => '.hg/branch' do |task|
64
- $stderr.puts "Updating the changelog..."
65
- begin
66
- content = make_changelog()
67
- rescue NoMethodError
68
- abort "This task requires hoe-mercurial (gem install hoe-mercurial)"
69
- end
70
- File.open( task.name, 'w', 0644 ) do |fh|
71
- fh.print( content )
72
- end
73
- end
60
+ # Run the tests before checking in
61
+ task 'hg:precheckin' => [ :check_history, :check_manifest, :gemspec, :spec ]
74
62
 
75
63
  # Rebuild the ChangeLog immediately before release
76
64
  task :prerelease => 'ChangeLog'
65
+ CLOBBER.include( 'ChangeLog' )
77
66
 
78
- # Simplecov
79
67
  desc "Build a coverage report"
80
68
  task :coverage do
81
69
  ENV["COVERAGE"] = 'yes'
82
70
  Rake::Task[:spec].invoke
83
71
  end
72
+
73
+
74
+ # Use the fivefish formatter for docs generated from development checkout
75
+ if File.directory?( '.hg' )
76
+ require 'rdoc/task'
77
+
78
+ Rake::Task[ 'docs' ].clear
79
+ RDoc::Task.new( 'docs' ) do |rdoc|
80
+ rdoc.main = "README.rdoc"
81
+ rdoc.rdoc_files.include( "*.rdoc", "*.md", "ChangeLog", "lib/**/*.rb" )
82
+ rdoc.generator = :fivefish
83
+ rdoc.title = 'Ruby WordNet'
84
+ rdoc.rdoc_dir = 'doc'
85
+ end
86
+ end
87
+
88
+ task :gemspec => [ 'ChangeLog', GEMSPEC ]
89
+ file GEMSPEC => __FILE__ do |task|
90
+ spec = $hoespec.spec
91
+ spec.files.delete( '.gemtest' )
92
+ spec.signing_key = nil
93
+ spec.version = "#{spec.version.bump}.0.pre#{Time.now.strftime("%Y%m%d%H%M%S")}"
94
+ spec.cert_chain = [ 'certs/ged.pem' ]
95
+ File.open( task.name, 'w' ) do |fh|
96
+ fh.write( spec.to_ruby )
97
+ end
98
+ end
99
+ CLOBBER.include( GEMSPEC )
100
+
101
+ task :default => :gemspec
102
+
@@ -0,0 +1,26 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEbDCCAtSgAwIBAgIBATANBgkqhkiG9w0BAQsFAD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
18
+ FI0PJ4y5I8buU4IZGUD5NEt/N7pZNfOyBxkrZkXhS44Fp+xwBH5ebLbq/WY78Bqd
19
+ db0z6ZgW4LMYMpWFfbXsRbd9TU2f52L8oMAhxOvF7Of5qJMVWuFQ8FPagk2iHrdH
20
+ inYLQagqAF6goWTXgAJCdPd6SNeeSNqA6vlY7CV1Jh5kfNJJ6xu/CVij1GzCLu/5
21
+ DMOr26DBv+qLJRRC/2h34uX71q5QgeOyxvMg+7V3u/Q06DXyQ2VgeeqiwDFFpEH0
22
+ PFkdPO6ZqbTRcLfNH7mFgCBJjsfSjJrn0sPBlYyOXgCoByfZnZyrIMH/UY+lgQqS
23
+ 6Von1VDsfQm0eJh5zYZD64ZF86phSR7mUX3mXItwH04HrZwkWpvgd871DZVR3i1n
24
+ w8aNA5re5+Rt/Vvjxj5AcEnZnZiz5x959NaddQocX32Z1unHw44pzRNUur1GInfW
25
+ p4vpx2kUSFSAGjtCbDGTNV2AH8w9OU4xEmNz8c5lyoA=
26
+ -----END CERTIFICATE-----
@@ -1,54 +1,44 @@
1
- #!/usr/bin/ruby -w
1
+ #!/usr/bin/env ruby
2
+ #encoding: utf-8
3
+
2
4
  #
3
5
  # Find least general hypernymial synsets between all noun senses of two words.
4
6
  #
5
7
 
6
8
  $LOAD_PATH.unshift "lib"
7
- require "wordnet"
9
+
10
+ require 'wordnet'
11
+ require 'loggability'
8
12
 
9
13
  raise RuntimeError, "You must specify two words." if ARGV.length != 2
10
14
 
11
- # Create the lexicon
12
15
  lex = WordNet::Lexicon.new
13
16
 
14
- # Look up the synsets for the specified word
15
- word1Syns = lex.lookup_synsets( ARGV[0], WordNet::Noun )
16
- word2Syns = lex.lookup_synsets( ARGV[1], WordNet::Noun )
17
+ word1_syns = lex.lookup_synsets( ARGV[0], :noun )
18
+ word2_syns = lex.lookup_synsets( ARGV[1], :noun )
17
19
 
18
- def debugMsg( message )
19
- return unless $DEBUG
20
- $stderr.puts message
21
- end
20
+ logger = Loggability[ WordNet ]
22
21
 
23
22
  # Use the analyzer to traverse hypernyms of the synset, adding a string for each
24
23
  # one with indentation for the level
25
- word1Syns.each {|syn|
26
- debugMsg( ">>> Searching with #{syn.wordlist} as the origin." )
24
+ word1_syns.each do |syn|
25
+ logger.debug ">>> Searching with #{syn.wordlist.join(', ')} as the origin."
27
26
 
28
- word2Syns.each {|secondSyn|
29
- debugMsg( " Comparing #{secondSyn.wordlist} to the origin." )
27
+ word2_syns.each do |syn2|
28
+ logger.debug " Comparing #{syn2.wordlist.join(', ')} to the origin."
30
29
 
31
- # The intersection of the two syns is the most-specific hypernym they
30
+ # The intersection of the two synsets is the most-specific hypernym they
32
31
  # share in common.
33
- commonSyn = (syn | secondSyn)
34
-
35
- if commonSyn
36
- puts <<-"EOF".gsub( /^\t{3}/, '' )
37
- ----
38
- #{syn.words.join(', ')}
39
- #{syn.gloss}
40
- and
41
- #{secondSyn.words.join(', ')}
42
- #{secondSyn.gloss}
43
- are both instances of
44
- #{commonSyn.words.join(', ')}
45
- #{commonSyn.gloss}.
46
- ----
47
- EOF
32
+ common_syn = (syn | syn2)
33
+
34
+ # Skip common synsets that are too abstract
35
+ if common_syn && common_syn.lexical_domain != 'noun.tops'
36
+ puts syn, syn2, ' ' + common_syn.to_s, ''
48
37
  else
49
- debugMsg( " No synsets in common." )
38
+ logger.debug " No synsets in common."
50
39
  end
51
- }
40
+ end
41
+
42
+ logger.debug " done with #{syn.wordlist}"
43
+ end
52
44
 
53
- debugMsg( " done with #{syn.wordlist}" )
54
- }
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+ #encoding: utf-8
3
+
4
+ #
5
+ # Find all the hypernyms of all senses of a given noun and display them in a
6
+ # heirarchy
7
+ #
8
+
9
+ $LOAD_PATH.unshift "lib"
10
+ require 'wordnet'
11
+
12
+ raise RuntimeError, "No word specified." if ARGV.empty?
13
+
14
+ # Create the lexicon
15
+ lex = WordNet::Lexicon.new
16
+
17
+ # Look up the synsets for the specified word
18
+ origins = lex.lookup_synsets( *ARGV )
19
+
20
+
21
+ # Iterate over the synsets for the different senses of the word
22
+ origins.each.with_index do |syn, i|
23
+ hypernyms = []
24
+
25
+ # Traverse the hypernyms
26
+ syn.traverse( :hypernyms ).with_depth.each do |hyper_syn, depth|
27
+ indent = ' ' * depth
28
+ hypernyms << "%s%s" % [ indent, hyper_syn ]
29
+ end
30
+
31
+ puts "\nHypernym tree for #{syn} (sense #{i + 1}):", *hypernyms
32
+ puts "Tree has #{hypernyms.length} synsets."
33
+ end
34
+
@@ -15,14 +15,14 @@ module WordNet
15
15
 
16
16
 
17
17
  # Release version
18
- VERSION = '1.0.0'
18
+ VERSION = '1.0.1'
19
19
 
20
20
  # VCS revision
21
21
  REVISION = %q$Revision: $
22
22
 
23
- # Abort if not >=1.9.2
24
- abort "This version of WordNet requires Ruby 1.9.3 or greater." unless
25
- RUBY_VERSION >= '1.9.3'
23
+ # Abort if not >=2.2.0
24
+ abort "This version of WordNet requires Ruby 2.2.0 or greater." unless
25
+ RUBY_VERSION >= '2.2.0'
26
26
 
27
27
 
28
28
  ### Lexicon exception - something has gone wrong in the internals of the
@@ -1,4 +1,5 @@
1
- #!/usr/bin/ruby
1
+ # -*- ruby -*-
2
+ #encoding: utf-8
2
3
 
3
4
  require 'wordnet' unless defined?( WordNet )
4
5
 
@@ -1,4 +1,5 @@
1
- #!/usr/bin/ruby
1
+ # -*- ruby -*-
2
+ #encoding: utf-8
2
3
 
3
4
  require 'wordnet' unless defined?( WordNet )
4
5
  require 'wordnet/synset' unless defined?( WordNet::Synset )
@@ -1,4 +1,5 @@
1
- #!/usr/bin/ruby
1
+ # -*- ruby -*-
2
+ #encoding: utf-8
2
3
 
3
4
  require 'pathname'
4
5
  require 'loggability'
@@ -16,8 +17,8 @@ require 'wordnet/word'
16
17
  #
17
18
  # == Creating a Lexicon
18
19
  #
19
- # To create a Lexicon, point it at a database using [Sequel database connection
20
- # criteria]{http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html}:
20
+ # To create a Lexicon, point it at a database using {Sequel database connection
21
+ # criteria}[http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html]:
21
22
  #
22
23
  # lex = WordNet::Lexicon.new( 'postgres://localhost/wordnet30' )
23
24
  # # => #<WordNet::Lexicon:0x7fd192a76668 postgres://localhost/wordnet30>
@@ -88,7 +89,7 @@ require 'wordnet/word'
88
89
  # If you're using a database that supports using regular expressions (e.g.,
89
90
  # PostgreSQL), you can use that to select one with a matching definition:
90
91
  #
91
- # lex[ :language, %r:name.*discipline: ]
92
+ # lex[ :language, /name.*discipline/ ]
92
93
  # # => #<WordNet::Synset:0x7ffa78f235a8 {106304059} 'language, nomenclature,
93
94
  # # terminology' (noun): [noun.communication] a system of words used
94
95
  # # to name things in a particular discipline>
@@ -316,7 +317,7 @@ class WordNet::Lexicon
316
317
  else
317
318
  pattern = "%%%s%%" % [ arg ]
318
319
  self.log.debug " filter: definition LIKE %p" % [ pattern ]
319
- dataset = dataset.filter { :definition.like(pattern) }
320
+ dataset = dataset.filter { Sequel.like(:definition, pattern) }
320
321
  end
321
322
  end
322
323
  end
@@ -1,4 +1,5 @@
1
- #!/usr/bin/ruby
1
+ # -*- ruby -*-
2
+ #encoding: utf-8
2
3
 
3
4
  require 'loggability'
4
5
  require 'sequel'
@@ -1,4 +1,5 @@
1
- #!/usr/bin/ruby
1
+ # -*- ruby -*-
2
+ #encoding: utf-8
2
3
 
3
4
  require 'wordnet' unless defined?( WordNet )
4
5
  require 'wordnet/model'
@@ -1,4 +1,5 @@
1
- #!/usr/bin/ruby
1
+ # -*- ruby -*-
2
+ #encoding: utf-8
2
3
 
3
4
  require 'wordnet' unless defined?( WordNet )
4
5
  require 'wordnet/constants'