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
@@ -1,30 +1,9 @@
1
- #!/usr/bin/env ruby
2
-
3
- BEGIN {
4
- require 'pathname'
5
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent
6
-
7
- libdir = basedir + 'lib'
8
-
9
- $LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
10
- $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
11
- }
1
+ #!/usr/bin/env rspec
2
+ require_relative '../helpers'
12
3
 
13
4
  require 'rspec'
14
5
  require 'sequel'
15
6
 
16
- # Use Sequel's own spec helpers
17
- if Gem::Specification.respond_to?( :find_by_name )
18
- sequel_spec = Gem::Specification.find_by_name( 'sequel' )
19
- gem_basedir = sequel_spec.full_gem_path
20
- $LOAD_PATH.unshift( gem_basedir ) unless $LOAD_PATH.include?( gem_basedir )
21
- else
22
- gem_basedir = Pathname( Gem.required_location('sequel', 'sequel.rb') ).dirname.parent.to_s
23
- $LOAD_PATH.unshift( gem_basedir ) unless $LOAD_PATH.include?( gem_basedir )
24
- end
25
- require 'spec/model/spec_helper'
26
-
27
- require 'spec/lib/helpers'
28
7
  require 'wordnet'
29
8
  require 'wordnet/model'
30
9
 
@@ -33,27 +12,16 @@ require 'wordnet/model'
33
12
  ### C O N T E X T S
34
13
  #####################################################################
35
14
 
36
- describe WordNet::Model do
15
+ DB = Sequel.connect( 'mock://postgres' )
37
16
 
38
- before( :all ) do
39
- setup_logging( :fatal )
40
- end
41
-
42
- before( :each ) do
43
- MODEL_DB.reset
44
- end
45
-
46
- after( :all ) do
47
- reset_logging()
48
- end
17
+ describe WordNet::Model do
49
18
 
50
19
  it "propagates database handle changes to all of its subclasses" do
51
20
  subclass = WordNet::Model( :tests )
52
21
  newdb = Sequel.mock
53
22
  WordNet::Model.db = newdb
54
- subclass.db.should equal( newdb )
23
+ expect( subclass.db ).to equal( newdb )
55
24
  end
56
25
 
57
-
58
26
  end
59
27
 
@@ -1,17 +1,7 @@
1
- #!/usr/bin/env ruby
2
-
3
- BEGIN {
4
- require 'pathname'
5
-
6
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent
7
- libdir = basedir + 'lib'
8
-
9
- $LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
10
- $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
11
- }
1
+ #!/usr/bin/env rspec
2
+ require_relative '../helpers'
12
3
 
13
4
  require 'rspec'
14
- require 'spec/lib/helpers'
15
5
  require 'wordnet/semanticlink'
16
6
 
17
7
 
@@ -20,16 +10,6 @@ require 'wordnet/semanticlink'
20
10
  #####################################################################
21
11
 
22
12
  describe WordNet::SemanticLink, :requires_database => true do
23
- include WordNet::SpecHelpers
24
-
25
- before( :all ) do
26
- setup_logging( :fatal )
27
- end
28
-
29
- after( :all ) do
30
- reset_logging()
31
- end
32
-
33
13
 
34
14
  let( :lexicon ) { WordNet::Lexicon.new }
35
15
  let( :word ) { lexicon[96814] } # 'parody'
@@ -38,16 +18,16 @@ describe WordNet::SemanticLink, :requires_database => true do
38
18
 
39
19
 
40
20
  it "links two synsets together" do
41
- semlink.origin.should be_a( WordNet::Synset )
42
- semlink.target.should be_a( WordNet::Synset )
21
+ expect( semlink.origin ).to be_a( WordNet::Synset )
22
+ expect( semlink.target ).to be_a( WordNet::Synset )
43
23
  end
44
24
 
45
25
  it "has a Symbolic type" do
46
- semlink.type.should == :hypernym
26
+ expect( semlink.type ).to eq( :hypernym )
47
27
  end
48
28
 
49
29
  it "has a human-readable type name" do
50
- semlink.typename.should == 'hypernym'
30
+ expect( semlink.typename ).to eq( 'hypernym' )
51
31
  end
52
32
 
53
33
 
@@ -0,0 +1,80 @@
1
+ #!/usr/bin/env rspec -cfd
2
+
3
+ require_relative '../helpers'
4
+
5
+ require 'wordnet/sense'
6
+
7
+
8
+ describe WordNet::Sense, :requires_database => true do
9
+
10
+ before( :all ) do
11
+ @lexicon = WordNet::Lexicon.new
12
+ end
13
+
14
+
15
+ let( :sense ) do
16
+ WordNet::Word[ 79712 ].senses.first
17
+ end
18
+
19
+
20
+ it "has a dataset for its 'also_see' lexical links" do
21
+ expect( sense.also_see ).to be_a( Sequel::Dataset )
22
+ end
23
+
24
+
25
+ it "has a dataset for its 'antonym' lexical links" do
26
+ expect( sense.antonym ).to be_a( Sequel::Dataset )
27
+ end
28
+
29
+
30
+ it "has a dataset for its 'derivation' lexical links" do
31
+ expect( sense.derivation ).to be_a( Sequel::Dataset )
32
+ end
33
+
34
+
35
+ it "has a dataset for its 'domain_categories' lexical links" do
36
+ expect( sense.domain_categories ).to be_a( Sequel::Dataset )
37
+ end
38
+
39
+
40
+ it "has a dataset for its 'domain_member_categories' lexical links" do
41
+ expect( sense.domain_member_categories ).to be_a( Sequel::Dataset )
42
+ end
43
+
44
+
45
+ it "has a dataset for its 'domain_member_region' lexical links" do
46
+ expect( sense.domain_member_region ).to be_a( Sequel::Dataset )
47
+ end
48
+
49
+
50
+ it "has a dataset for its 'domain_member_usage' lexical links" do
51
+ expect( sense.domain_member_usage ).to be_a( Sequel::Dataset )
52
+ end
53
+
54
+
55
+ it "has a dataset for its 'domain_region' lexical links" do
56
+ expect( sense.domain_region ).to be_a( Sequel::Dataset )
57
+ end
58
+
59
+
60
+ it "has a dataset for its 'domain_usage' lexical links" do
61
+ expect( sense.domain_usage ).to be_a( Sequel::Dataset )
62
+ end
63
+
64
+
65
+ it "has a dataset for its 'participle' lexical links" do
66
+ expect( sense.participle ).to be_a( Sequel::Dataset )
67
+ end
68
+
69
+
70
+ it "has a dataset for its 'pertainym' lexical links" do
71
+ expect( sense.pertainym ).to be_a( Sequel::Dataset )
72
+ end
73
+
74
+
75
+ it "has a dataset for its 'verb_group' lexical links" do
76
+ expect( sense.verb_group ).to be_a( Sequel::Dataset )
77
+ end
78
+
79
+ end
80
+
@@ -1,17 +1,7 @@
1
- #!/usr/bin/env ruby
2
-
3
- BEGIN {
4
- require 'pathname'
5
-
6
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent
7
- libdir = basedir + 'lib'
8
-
9
- $LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
10
- $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
11
- }
1
+ #!/usr/bin/env rspec
2
+ require_relative '../helpers'
12
3
 
13
4
  require 'rspec'
14
- require 'spec/lib/helpers'
15
5
  require 'wordnet/synset'
16
6
 
17
7
 
@@ -20,36 +10,30 @@ require 'wordnet/synset'
20
10
  #####################################################################
21
11
 
22
12
  describe WordNet::Synset, :requires_database => true do
23
- include WordNet::SpecHelpers
24
13
 
25
14
  before( :all ) do
26
- setup_logging( :fatal )
27
15
  @lexicon = WordNet::Lexicon.new
28
16
  end
29
17
 
30
- after( :all ) do
31
- reset_logging()
32
- end
33
-
34
18
 
35
19
  it "knows what kinds of lexical domains are available" do
36
- described_class.lexdomains.should be_a( Hash )
37
- described_class.lexdomains.should include( 'noun.cognition' )
38
- described_class.lexdomains['noun.cognition'].should be_a( Hash )
39
- described_class.lexdomains['noun.cognition'][:pos].should == 'n'
20
+ expect( described_class.lexdomains ).to be_a( Hash )
21
+ expect( described_class.lexdomains ).to include( 'noun.cognition' )
22
+ expect( described_class.lexdomains['noun.cognition'] ).to be_a( Hash )
23
+ expect( described_class.lexdomains['noun.cognition'][:pos] ).to eq( 'n' )
40
24
  end
41
25
 
42
26
  it "knows what kinds of semantic links are available" do
43
- described_class.linktypes.should be_a( Hash )
27
+ expect( described_class.linktypes ).to be_a( Hash )
44
28
  hypernym = described_class.linktypes[:hypernym]
45
- hypernym.should be_a( Hash )
46
- hypernym[:typename].should == 'hypernym'
47
- hypernym[:recurses].should be_true()
29
+ expect( hypernym ).to be_a( Hash )
30
+ expect( hypernym[:typename] ).to eq( 'hypernym' )
31
+ expect( hypernym[:recurses] ).to be_truthy()
48
32
  end
49
33
 
50
34
  it "knows what parts of speech are supported" do
51
- described_class.postypes.should be_a( Hash )
52
- described_class.postypes['noun'].should == :n
35
+ expect( described_class.postypes ).to be_a( Hash )
36
+ expect( described_class.postypes['noun'] ).to eq( :n )
53
37
  end
54
38
 
55
39
 
@@ -62,42 +46,42 @@ describe WordNet::Synset, :requires_database => true do
62
46
 
63
47
 
64
48
  it "knows what lexical domain it's from" do
65
- synset.lexical_domain.should == 'noun.artifact'
49
+ expect( synset.lexical_domain ).to eq( 'noun.artifact' )
66
50
  end
67
51
 
68
52
  it "can make a Sequel dataset for any of its semantic link relationships" do
69
53
  ds = synset.semanticlink_dataset( :member_meronyms )
70
- ds.should be_a( Sequel::Dataset )
71
- ds.first_source_table.should == :synsets
54
+ expect( ds ).to be_a( Sequel::Dataset )
55
+ expect( ds.first_source_table ).to eq( :synsets )
72
56
  end
73
57
 
74
58
  it "can make an Enumerator for any of its semantic link relationships" do
75
59
  enum = synset.semanticlink_enum( :member_meronyms )
76
- enum.should be_a( Enumerator )
60
+ expect( enum ).to be_a( Enumerator )
77
61
  end
78
62
 
79
63
  it "can recursively traverse its semantic links" do
80
64
  res = synset.traverse( :hypernyms ).to_a
81
- res.should have( 6 ).members
82
- res.should == [
65
+ expect( res.size ).to eq( 6 )
66
+ expect( res ).to eq([
83
67
  WordNet::Synset[ 104341686 ],
84
68
  WordNet::Synset[ 100021939 ],
85
69
  WordNet::Synset[ 100003553 ],
86
70
  WordNet::Synset[ 100002684 ],
87
71
  WordNet::Synset[ 100001930 ],
88
72
  WordNet::Synset[ 100001740 ],
89
- ]
73
+ ])
90
74
  end
91
75
 
92
76
  it "can return an Enumerator for recursively traversing its semantic links" do
93
77
  enum = synset.traverse( :hypernyms )
94
78
 
95
- enum.next.should == WordNet::Synset[ 104341686 ]
96
- enum.next.should == WordNet::Synset[ 100021939 ]
97
- enum.next.should == WordNet::Synset[ 100003553 ]
98
- enum.next.should == WordNet::Synset[ 100002684 ]
99
- enum.next.should == WordNet::Synset[ 100001930 ]
100
- enum.next.should == WordNet::Synset[ 100001740 ]
79
+ expect( enum.next ).to eq( WordNet::Synset[ 104341686 ] )
80
+ expect( enum.next ).to eq( WordNet::Synset[ 100021939 ] )
81
+ expect( enum.next ).to eq( WordNet::Synset[ 100003553 ] )
82
+ expect( enum.next ).to eq( WordNet::Synset[ 100002684 ] )
83
+ expect( enum.next ).to eq( WordNet::Synset[ 100001930 ] )
84
+ expect( enum.next ).to eq( WordNet::Synset[ 100001740 ] )
101
85
  expect {
102
86
  enum.next
103
87
  }.to raise_error( StopIteration )
@@ -111,17 +95,19 @@ describe WordNet::Synset, :requires_database => true do
111
95
 
112
96
  it "can find the hypernym that it and another synset share in common through the intersection operator" do
113
97
  res = synset | @lexicon[ :squire ]
114
- res.should == @lexicon[:person]
98
+ expect( res ).to eq( @lexicon[:person] )
115
99
  end
116
100
 
117
101
  it "knows what part of speech it's for" do
118
- synset.part_of_speech.should == 'noun'
102
+ expect( synset.part_of_speech ).to eq( 'noun' )
119
103
  end
120
104
 
121
105
  it "stringifies as a readable definition" do
122
- synset.to_s.should == "knight (noun): [noun.person] originally a person of noble birth trained to " +
106
+ expect(
107
+ synset.to_s
108
+ ).to eq( "knight (noun): [noun.person] originally a person of noble birth trained to " +
123
109
  "arms and chivalry; today in Great Britain a person honored by the sovereign for personal " +
124
- "merit (hypernym: 1, hyponym: 6, instance hyponym: 1)"
110
+ "merit (hypernym: 1, hyponym: 6, instance hyponym: 1)" )
125
111
  end
126
112
 
127
113
  end
@@ -132,8 +118,8 @@ describe WordNet::Synset, :requires_database => true do
132
118
  let( :synset ) { @lexicon[:congener] }
133
119
 
134
120
  it "can look up its sample sentences" do
135
- synset.samples.should have( 2 ).members
136
- synset.samples.should include(
121
+ expect( synset.samples.size ).to eq( 2 )
122
+ expect( synset.samples ).to include(
137
123
  "lard was also used, though its congener, butter, was more frequently employed",
138
124
  "the American shopkeeper differs from his European congener"
139
125
  )
@@ -1,17 +1,7 @@
1
- #!/usr/bin/env ruby
2
-
3
- BEGIN {
4
- require 'pathname'
5
-
6
- basedir = Pathname.new( __FILE__ ).dirname.parent.parent
7
- libdir = basedir + 'lib'
8
-
9
- $LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
10
- $LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
11
- }
1
+ #!/usr/bin/env rspec
2
+ require_relative '../helpers'
12
3
 
13
4
  require 'rspec'
14
- require 'spec/lib/helpers'
15
5
  require 'wordnet'
16
6
  require 'wordnet/word'
17
7
 
@@ -21,16 +11,6 @@ require 'wordnet/word'
21
11
  #####################################################################
22
12
 
23
13
  describe WordNet::Word, :requires_database => true do
24
- include WordNet::SpecHelpers
25
-
26
- before( :all ) do
27
- setup_logging( :fatal )
28
- end
29
-
30
- after( :all ) do
31
- reset_logging()
32
- end
33
-
34
14
 
35
15
  let( :lexicon ) { WordNet::Lexicon.new }
36
16
 
@@ -41,24 +21,24 @@ describe WordNet::Word, :requires_database => true do
41
21
 
42
22
  it "knows what senses it has" do
43
23
  senses = word.senses
44
- senses.should be_an( Array )
45
- senses.should have( 57 ).members
46
- senses.first.should be_a( WordNet::Sense )
24
+ expect( senses ).to be_an( Array )
25
+ expect( senses.count ).to eq( 57 )
26
+ expect( senses.first ).to be_a( WordNet::Sense )
47
27
  end
48
28
 
49
29
  it "knows what synsets it has" do
50
30
  synsets = word.synsets
51
31
 
52
32
  # Should have one synset per sense
53
- synsets.should have( word.senses.length ).members
54
- synsets.first.senses.should include( word.senses.first )
33
+ expect( synsets.size ).to eq( word.senses.size )
34
+ expect( synsets.first.senses ).to include( word.senses.first )
55
35
  end
56
36
 
57
37
  it "has a dataset for selecting noun synsets" do
58
- word.nouns.should be_a( Sequel::Dataset )
59
- word.nouns.should have( 16 ).members
38
+ expect( word.nouns ).to be_a( Sequel::Dataset )
39
+ expect( word.nouns.count ).to eq( 16 )
60
40
  ss = word.nouns.all
61
- ss.should include(
41
+ expect( ss ).to include(
62
42
  lexicon[ :run, 'sequence' ],
63
43
  lexicon[ :run, 'baseball' ],
64
44
  lexicon[ :run, 'act of running' ],
@@ -67,10 +47,10 @@ describe WordNet::Word, :requires_database => true do
67
47
  end
68
48
 
69
49
  it "has a dataset for selecting verb synsets" do
70
- word.verbs.should be_a( Sequel::Dataset )
71
- word.verbs.should have( 41 ).members
50
+ expect( word.verbs ).to be_a( Sequel::Dataset )
51
+ expect( word.verbs.count ).to eq( 41 )
72
52
  ss = word.verbs.all
73
- ss.should include(
53
+ expect( ss ).to include(
74
54
  lexicon[ :run, 'compete' ],
75
55
  lexicon[ :run, 'be diffused' ],
76
56
  lexicon[ :run, 'liquid' ],
@@ -86,10 +66,10 @@ describe WordNet::Word, :requires_database => true do
86
66
  let( :word ) { lexicon[77458] }
87
67
 
88
68
  it "has a dataset for selecting adjective synsets" do
89
- word.adjectives.should be_a( Sequel::Dataset )
90
- word.adjectives.should have( 8 ).members
69
+ expect( word.adjectives ).to be_a( Sequel::Dataset )
70
+ expect( word.adjectives.count ).to eq( 8 )
91
71
  ss = word.adjectives.all
92
- ss.should include(
72
+ expect( ss ).to include(
93
73
  lexicon[ :light, 'weight' ],
94
74
  lexicon[ :light, 'emit', :adjective ],
95
75
  lexicon[ :light, 'color' ]
@@ -97,10 +77,10 @@ describe WordNet::Word, :requires_database => true do
97
77
  end
98
78
 
99
79
  it "has a dataset for selecting adjective-satellite synsets" do
100
- word.adjective_satellites.should be_a( Sequel::Dataset )
101
- word.adjective_satellites.should have( 17 ).members
80
+ expect( word.adjective_satellites ).to be_a( Sequel::Dataset )
81
+ expect( word.adjective_satellites.count ).to eq( 17 )
102
82
  ss = word.adjective_satellites.all
103
- ss.should include(
83
+ expect( ss ).to include(
104
84
  lexicon[ :light, 'soil' ],
105
85
  lexicon[ :light, 'calories' ],
106
86
  lexicon[ :light, 'entertainment' ]
@@ -115,10 +95,10 @@ describe WordNet::Word, :requires_database => true do
115
95
  let( :word ) { lexicon[77549] }
116
96
 
117
97
  it "has a dataset for selecting adverb synsets" do
118
- word.adverbs.should be_a( Sequel::Dataset )
119
- word.adverbs.should have( 7 ).members
98
+ expect( word.adverbs ).to be_a( Sequel::Dataset )
99
+ expect( word.adverbs.count ).to eq( 7 )
120
100
  ss = word.adverbs.all
121
- ss.should include(
101
+ expect( ss ).to include(
122
102
  lexicon[ :lightly, 'indifference' ],
123
103
  lexicon[ :lightly, 'indulging' ],
124
104
  lexicon[ :lightly, 'little weight' ],