wordnet 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.gems +5 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.simplecov +8 -0
- data/Gemfile +2 -0
- data/History.rdoc +7 -0
- data/Manifest.txt +11 -12
- data/README.md +1 -0
- data/Rakefile +44 -25
- data/certs/ged.pem +26 -0
- data/examples/gcs.rb +24 -34
- data/examples/hypernym_tree.rb +34 -0
- data/lib/wordnet.rb +4 -4
- data/lib/wordnet/constants.rb +2 -1
- data/lib/wordnet/lexicallink.rb +2 -1
- data/lib/wordnet/lexicon.rb +6 -5
- data/lib/wordnet/model.rb +2 -1
- data/lib/wordnet/morph.rb +2 -1
- data/lib/wordnet/semanticlink.rb +2 -1
- data/lib/wordnet/sense.rb +48 -4
- data/lib/wordnet/sumoterm.rb +3 -2
- data/lib/wordnet/synset.rb +12 -10
- data/lib/wordnet/word.rb +21 -20
- data/spec/helpers.rb +43 -0
- data/spec/wordnet/lexicon_spec.rb +44 -61
- data/spec/wordnet/model_spec.rb +5 -37
- data/spec/wordnet/semanticlink_spec.rb +6 -26
- data/spec/wordnet/sense_spec.rb +80 -0
- data/spec/wordnet/synset_spec.rb +33 -47
- data/spec/wordnet/word_spec.rb +22 -42
- data/spec/wordnet_spec.rb +4 -23
- data/wordnet.gemspec +63 -0
- metadata +110 -113
- metadata.gz.sig +0 -0
- data/.gemtest +0 -0
- data/examples/add-laced-boots.rb +0 -35
- data/examples/clothes-with-collars.rb +0 -42
- data/examples/clothesWithTongues.rb +0 -28
- data/examples/distance.rb +0 -37
- data/examples/domainTree.rb +0 -27
- data/examples/holonymTree.rb +0 -27
- data/examples/hypernymTree.rb +0 -28
- data/examples/hyponymTree.rb +0 -28
- data/examples/memberTree.rb +0 -27
- data/examples/meronymTree.rb +0 -29
- data/spec/lib/helpers.rb +0 -80
- data/spec/linguawordnet.tests.rb +0 -38
data/lib/wordnet/sense.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
# -*- ruby -*-
|
2
|
+
#encoding: utf-8
|
2
3
|
|
3
4
|
require 'wordnet' unless defined?( WordNet )
|
4
5
|
require 'wordnet/model'
|
@@ -9,9 +10,16 @@ class WordNet::Sense < WordNet::Model( :senses )
|
|
9
10
|
|
10
11
|
set_primary_key :senseid
|
11
12
|
|
13
|
+
##
|
14
|
+
# The Synset this is a Sense for
|
12
15
|
many_to_one :synset, :key => :synsetid
|
16
|
+
|
17
|
+
##
|
18
|
+
# The Word this is a Sense for
|
13
19
|
many_to_one :word, :key => :wordid
|
14
20
|
|
21
|
+
##
|
22
|
+
# The lexical links between this sense and its related Synsets.
|
15
23
|
# Sense -> [ LexicalLinks ] -> [ Synsets ]
|
16
24
|
one_to_many :lexlinks,
|
17
25
|
:class => :"WordNet::LexicalLink",
|
@@ -21,35 +29,71 @@ class WordNet::Sense < WordNet::Model( :senses )
|
|
21
29
|
|
22
30
|
### Generate a method that will return Synsets related by the given lexical pointer
|
23
31
|
### +type+.
|
24
|
-
def self::lexical_link( type, typekey=nil )
|
32
|
+
def self::lexical_link( type, typekey=nil ) # :nodoc:
|
25
33
|
typekey ||= type.to_s.chomp( 's' ).to_sym
|
26
34
|
|
27
35
|
self.log.debug "Generating a %p method for %p links" % [ type, typekey ]
|
28
36
|
|
29
37
|
method_body = Proc.new do
|
30
|
-
linkinfo = WordNet::Synset.
|
38
|
+
linkinfo = WordNet::Synset.linktypes[ typekey ] or
|
31
39
|
raise ScriptError, "no such link type %p" % [ typekey ]
|
32
40
|
ssids = self.lexlinks_dataset.filter( :linkid => linkinfo[:id] ).select( :synset2id )
|
33
41
|
self.class.filter( :synsetid => ssids )
|
34
42
|
end
|
35
|
-
self.log.debug " method body is: %p" % [ method_body ]
|
36
43
|
|
37
44
|
define_method( type, &method_body )
|
38
45
|
end
|
39
46
|
|
40
47
|
|
48
|
+
##
|
49
|
+
# Return the synsets that are lexically linked to this sense via an "also see" link.
|
41
50
|
lexical_link :also_see, :also
|
51
|
+
|
52
|
+
##
|
53
|
+
# Return the synsets that are lexically linked to this sense via an "antonym" link.
|
42
54
|
lexical_link :antonym
|
55
|
+
|
56
|
+
##
|
57
|
+
# Return the synsets that are lexically linked to this sense via a "derivation" link.
|
43
58
|
lexical_link :derivation
|
59
|
+
|
60
|
+
##
|
61
|
+
# Return the synsets that are lexically linked to this sense via a "domain category" link.
|
44
62
|
lexical_link :domain_categories, :domain_category
|
63
|
+
|
64
|
+
##
|
65
|
+
# Return the synsets that are lexically linked to this sense via a "domain member
|
66
|
+
# category" link.
|
45
67
|
lexical_link :domain_member_categories, :domain_member_category
|
68
|
+
|
69
|
+
##
|
70
|
+
# Return the synsets that are lexically linked to this sense via a "domain member region" link.
|
46
71
|
lexical_link :domain_member_region
|
72
|
+
|
73
|
+
##
|
74
|
+
# Return the synsets that are lexically linked to this sense via a "domain member usage" link.
|
47
75
|
lexical_link :domain_member_usage
|
76
|
+
|
77
|
+
##
|
78
|
+
# Return the synsets that are lexically linked to this sense via a "domain region" link.
|
48
79
|
lexical_link :domain_region
|
80
|
+
|
81
|
+
##
|
82
|
+
# Return the synsets that are lexically linked to this sense via a "domain usage" link.
|
49
83
|
lexical_link :domain_usage
|
84
|
+
|
85
|
+
##
|
86
|
+
# Return the synsets that are lexically linked to this sense via a "participle" link.
|
50
87
|
lexical_link :participle
|
88
|
+
|
89
|
+
##
|
90
|
+
# Return the synsets that are lexically linked to this sense via a "pertainym" link.
|
51
91
|
lexical_link :pertainym
|
92
|
+
|
93
|
+
##
|
94
|
+
# Return the synsets that are lexically linked to this sense via a "verb group" link.
|
52
95
|
lexical_link :verb_group
|
53
96
|
|
97
|
+
|
54
98
|
end # class WordNet::Sense
|
55
99
|
|
data/lib/wordnet/sumoterm.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
|
1
|
+
# -*- ruby -*-
|
2
|
+
#encoding: utf-8
|
2
3
|
|
3
4
|
require 'wordnet' unless defined?( WordNet )
|
4
5
|
require 'wordnet/model'
|
5
6
|
require 'wordnet/constants'
|
6
7
|
|
7
8
|
|
8
|
-
# Experimental support for the WordNet mapping for the {Suggested Upper Merged
|
9
|
+
# Experimental support for the WordNet mapping for the {Suggested Upper Merged
|
9
10
|
# Ontology}[http://www.ontologyportal.org/] (SUMO).
|
10
11
|
# This is still a work in progress, and isn't supported by all of the WordNet-SQL
|
11
12
|
# databases.
|
data/lib/wordnet/synset.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
# -*- ruby -*-
|
2
|
+
#encoding: utf-8
|
2
3
|
|
3
4
|
require 'wordnet' unless defined?( WordNet )
|
4
5
|
require 'wordnet/constants'
|
@@ -45,7 +46,7 @@ require 'wordnet/model'
|
|
45
46
|
# # => [#<WordNet::Synset:0x7ffbf25c76c8 {115180528} 'point, point in
|
46
47
|
# # time' (noun): [noun.time] an instant of time>]
|
47
48
|
#
|
48
|
-
# The synset's *
|
49
|
+
# The synset's *hyponyms*, on the other hand, are kind of like its
|
49
50
|
# subclasses:
|
50
51
|
#
|
51
52
|
# ss.hyponyms
|
@@ -101,7 +102,7 @@ require 'wordnet/model'
|
|
101
102
|
#
|
102
103
|
# In order to make use of this API, you'll need to be familiar with
|
103
104
|
# {Sequel}[http://sequel.rubyforge.org/], especially
|
104
|
-
# {Datasets}[http://sequel.rubyforge.org/rdoc/files/doc/dataset_basics_rdoc.html] and
|
105
|
+
# {Datasets}[http://sequel.rubyforge.org/rdoc/files/doc/dataset_basics_rdoc.html] and
|
105
106
|
# {Model Associations}[http://sequel.rubyforge.org/rdoc/files/doc/association_basics_rdoc.html].
|
106
107
|
# Most of Ruby-WordNet's functionality is implemented in terms of one or both
|
107
108
|
# of these.
|
@@ -176,7 +177,6 @@ class WordNet::Synset < WordNet::Model( :synsets )
|
|
176
177
|
set_primary_key :synsetid
|
177
178
|
|
178
179
|
##
|
179
|
-
# :singleton-method:
|
180
180
|
# The WordNet::Words associated with the receiver
|
181
181
|
many_to_many :words,
|
182
182
|
:join_table => :senses,
|
@@ -185,7 +185,6 @@ class WordNet::Synset < WordNet::Model( :synsets )
|
|
185
185
|
|
186
186
|
|
187
187
|
##
|
188
|
-
# :singleton-method:
|
189
188
|
# The WordNet::Senses associated with the receiver
|
190
189
|
one_to_many :senses,
|
191
190
|
:key => :synsetid,
|
@@ -193,7 +192,6 @@ class WordNet::Synset < WordNet::Model( :synsets )
|
|
193
192
|
|
194
193
|
|
195
194
|
##
|
196
|
-
# :singleton-method:
|
197
195
|
# The WordNet::SemanticLinks indicating a relationship with other
|
198
196
|
# WordNet::Synsets
|
199
197
|
one_to_many :semlinks,
|
@@ -204,7 +202,6 @@ class WordNet::Synset < WordNet::Model( :synsets )
|
|
204
202
|
|
205
203
|
|
206
204
|
##
|
207
|
-
# :singleton-method:
|
208
205
|
# The WordNet::SemanticLinks pointing *to* this Synset
|
209
206
|
many_to_one :semlinks_to,
|
210
207
|
:class => :"WordNet::SemanticLink",
|
@@ -213,7 +210,6 @@ class WordNet::Synset < WordNet::Model( :synsets )
|
|
213
210
|
|
214
211
|
|
215
212
|
##
|
216
|
-
# :singleton-method:
|
217
213
|
# Terms from the Suggested Upper Merged Ontology
|
218
214
|
many_to_many :sumo_terms,
|
219
215
|
:join_table => :sumomaps,
|
@@ -551,7 +547,7 @@ class WordNet::Synset < WordNet::Model( :synsets )
|
|
551
547
|
# tree, you can make a traversal enumerator for it:
|
552
548
|
#
|
553
549
|
# ss = $lex[:fencing]
|
554
|
-
# # => #<WordNet::Synset:0x7fb582c24400 {101171644} 'fencing' (noun): [noun.act] the art or
|
550
|
+
# # => #<WordNet::Synset:0x7fb582c24400 {101171644} 'fencing' (noun): [noun.act] the art or
|
555
551
|
# sport of fighting with swords (especially the use of foils or epees or sabres to score
|
556
552
|
# points under a set of rules)>
|
557
553
|
#
|
@@ -671,13 +667,19 @@ class WordNet::Synset < WordNet::Model( :synsets )
|
|
671
667
|
# :section:
|
672
668
|
#
|
673
669
|
|
670
|
+
### Return the Synset's Words as an Array of Strings.
|
671
|
+
def wordlist
|
672
|
+
return self.words.map( &:to_s )
|
673
|
+
end
|
674
|
+
|
675
|
+
|
674
676
|
### Return a human-readable representation of the objects, suitable for debugging.
|
675
677
|
def inspect
|
676
678
|
return "#<%p:%0#x {%d} '%s' (%s): [%s] %s>" % [
|
677
679
|
self.class,
|
678
680
|
self.object_id * 2,
|
679
681
|
self.synsetid,
|
680
|
-
self.
|
682
|
+
self.wordlist.join(', '),
|
681
683
|
self.part_of_speech,
|
682
684
|
self.lexical_domain,
|
683
685
|
self.definition,
|
data/lib/wordnet/word.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
# -*- ruby -*-
|
2
|
+
#encoding: utf-8
|
2
3
|
|
3
4
|
require 'wordnet' unless defined?( WordNet )
|
4
5
|
require 'wordnet/model'
|
@@ -17,43 +18,43 @@ class WordNet::Word < WordNet::Model( :words )
|
|
17
18
|
# "unq_words_lemma" UNIQUE, btree (lemma)
|
18
19
|
# Referenced by:
|
19
20
|
# TABLE "adjpositions" CONSTRAINT "fk_adjpositions_wordid"
|
20
|
-
#
|
21
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
21
22
|
# TABLE "bncconvtasks" CONSTRAINT "fk_bncconvtasks_wordid"
|
22
|
-
#
|
23
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
23
24
|
# TABLE "bncimaginfs" CONSTRAINT "fk_bncimaginfs_wordid"
|
24
|
-
#
|
25
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
25
26
|
# TABLE "bncs" CONSTRAINT "fk_bncs_wordid"
|
26
|
-
#
|
27
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
27
28
|
# TABLE "bncspwrs" CONSTRAINT "fk_bncspwrs_wordid"
|
28
|
-
#
|
29
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
29
30
|
# TABLE "casedwords" CONSTRAINT "fk_casedwords_wordid"
|
30
|
-
#
|
31
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
31
32
|
# TABLE "lexlinks" CONSTRAINT "fk_lexlinks_word1id"
|
32
|
-
#
|
33
|
+
# FOREIGN KEY (word1id) REFERENCES words(wordid)
|
33
34
|
# TABLE "lexlinks" CONSTRAINT "fk_lexlinks_word2id"
|
34
|
-
#
|
35
|
+
# FOREIGN KEY (word2id) REFERENCES words(wordid)
|
35
36
|
# TABLE "morphmaps" CONSTRAINT "fk_morphmaps_wordid"
|
36
|
-
#
|
37
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
37
38
|
# TABLE "sensemaps2021" CONSTRAINT "fk_sensemaps2021_wordid"
|
38
|
-
#
|
39
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
39
40
|
# TABLE "sensemaps2130" CONSTRAINT "fk_sensemaps2130_wordid"
|
40
|
-
#
|
41
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
41
42
|
# TABLE "senses20" CONSTRAINT "fk_senses20_wordid"
|
42
|
-
#
|
43
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
43
44
|
# TABLE "senses21" CONSTRAINT "fk_senses21_wordid"
|
44
|
-
#
|
45
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
45
46
|
# TABLE "senses" CONSTRAINT "fk_senses_wordid"
|
46
|
-
#
|
47
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
47
48
|
# TABLE "vframemaps" CONSTRAINT "fk_vframemaps_wordid"
|
48
|
-
#
|
49
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
49
50
|
# TABLE "vframesentencemaps" CONSTRAINT "fk_vframesentencemaps_wordid"
|
50
|
-
#
|
51
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
51
52
|
# TABLE "vnclassmembers" CONSTRAINT "fk_vnclassmembers_wordid"
|
52
|
-
#
|
53
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
53
54
|
# TABLE "vnframemaps" CONSTRAINT "fk_vnframemaps_wordid"
|
54
|
-
#
|
55
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
55
56
|
# TABLE "vnrolemaps" CONSTRAINT "fk_vnrolemaps_wordid"
|
56
|
-
#
|
57
|
+
# FOREIGN KEY (wordid) REFERENCES words(wordid)
|
57
58
|
|
58
59
|
|
59
60
|
set_primary_key :wordid
|
data/spec/helpers.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
#encoding: utf-8
|
3
|
+
# coding: utf-8
|
4
|
+
|
5
|
+
# SimpleCov test coverage reporting; enable this using the :coverage rake task
|
6
|
+
require 'simplecov' if ENV['COVERAGE']
|
7
|
+
|
8
|
+
require 'rspec'
|
9
|
+
require 'loggability/spechelpers'
|
10
|
+
require 'wordnet'
|
11
|
+
|
12
|
+
|
13
|
+
### RSpec helper functions.
|
14
|
+
module WordNet::SpecHelpers
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
### Mock with Rspec
|
19
|
+
RSpec.configure do |config|
|
20
|
+
config.run_all_when_everything_filtered = true
|
21
|
+
config.filter_run :focus
|
22
|
+
config.order = 'random'
|
23
|
+
config.mock_with( :rspec ) do |mock|
|
24
|
+
mock.syntax = :expect
|
25
|
+
end
|
26
|
+
|
27
|
+
if Gem::Specification.find_all_by_name( 'pg' ).empty?
|
28
|
+
config.filter_run_excluding( :requires_pg )
|
29
|
+
end
|
30
|
+
|
31
|
+
begin
|
32
|
+
uri = WordNet::Lexicon.default_db_uri
|
33
|
+
WordNet.log.info "Database tests will use: #{uri}"
|
34
|
+
rescue WordNet::LexiconError
|
35
|
+
config.filter_run_excluding( :requires_database )
|
36
|
+
end
|
37
|
+
|
38
|
+
config.include( WordNet::SpecHelpers )
|
39
|
+
config.include( Loggability::SpecHelpers )
|
40
|
+
end
|
41
|
+
|
42
|
+
# vim: set nosta noet ts=4 sw=4:
|
43
|
+
|
@@ -1,20 +1,8 @@
|
|
1
|
-
#!/usr/bin/env
|
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
|
-
require '
|
15
|
-
|
16
|
-
require 'spec/lib/helpers'
|
17
|
-
require 'wordnet'
|
5
|
+
require 'wordnet/lexicon'
|
18
6
|
|
19
7
|
|
20
8
|
#####################################################################
|
@@ -24,53 +12,48 @@ require 'wordnet'
|
|
24
12
|
describe WordNet::Lexicon do
|
25
13
|
|
26
14
|
before( :all ) do
|
27
|
-
setup_logging()
|
28
15
|
@devdb = Pathname( 'wordnet-defaultdb/data/wordnet-defaultdb/wordnet30.sqlite' ).
|
29
16
|
expand_path
|
30
17
|
end
|
31
18
|
|
32
|
-
after( :all ) do
|
33
|
-
reset_logging()
|
34
|
-
end
|
35
|
-
|
36
19
|
|
37
20
|
context "the default_db_uri method" do
|
38
21
|
|
39
22
|
it "uses the wordnet-defaultdb database gem (if available)" do
|
40
|
-
Gem.
|
23
|
+
expect( Gem ).to receive( :datadir ).with( 'wordnet-defaultdb' ).at_least( :once ).
|
41
24
|
and_return( '/tmp/foo' )
|
42
|
-
FileTest.
|
25
|
+
expect( FileTest ).to receive( :exist? ).with( '/tmp/foo/wordnet30.sqlite' ).
|
43
26
|
and_return( true )
|
44
27
|
|
45
|
-
WordNet::Lexicon.default_db_uri.
|
28
|
+
expect( WordNet::Lexicon.default_db_uri ).to eq( "sqlite:/tmp/foo/wordnet30.sqlite" )
|
46
29
|
end
|
47
30
|
|
48
31
|
it "uses the development version of the wordnet-defaultdb database gem if it's " +
|
49
32
|
"not installed" do
|
50
|
-
Gem.
|
33
|
+
expect( Gem ).to receive( :datadir ).with( 'wordnet-defaultdb' ).
|
51
34
|
and_return( nil )
|
52
|
-
FileTest.
|
35
|
+
expect( FileTest ).to receive( :exist? ).with( @devdb.to_s ).
|
53
36
|
and_return( true )
|
54
37
|
|
55
|
-
WordNet::Lexicon.default_db_uri.
|
38
|
+
expect( WordNet::Lexicon.default_db_uri ).to eq( "sqlite:#{@devdb}" )
|
56
39
|
end
|
57
40
|
|
58
41
|
it "returns nil if there is no default database" do
|
59
|
-
Gem.
|
42
|
+
expect( Gem ).to receive( :datadir ).with( 'wordnet-defaultdb' ).
|
60
43
|
and_return( nil )
|
61
|
-
FileTest.
|
44
|
+
expect( FileTest ).to receive( :exist? ).with( @devdb.to_s ).
|
62
45
|
and_return( false )
|
63
46
|
|
64
|
-
WordNet::Lexicon.default_db_uri.
|
47
|
+
expect( WordNet::Lexicon.default_db_uri ).to be_nil()
|
65
48
|
end
|
66
49
|
|
67
50
|
end
|
68
51
|
|
69
52
|
|
70
53
|
it "raises an exception if created with no arguments and no defaultdb is available" do
|
71
|
-
Gem.
|
54
|
+
expect( Gem ).to receive( :datadir ).with( 'wordnet-defaultdb' ).at_least( :once ).
|
72
55
|
and_return( nil )
|
73
|
-
FileTest.
|
56
|
+
expect( FileTest ).to receive( :exist? ).with( @devdb.to_s ).
|
74
57
|
and_return( false )
|
75
58
|
|
76
59
|
expect {
|
@@ -87,36 +70,36 @@ describe WordNet::Lexicon do
|
|
87
70
|
|
88
71
|
it "can look up a Synset by ID" do
|
89
72
|
rval = lexicon[ 101219722 ]
|
90
|
-
rval.
|
91
|
-
rval.words.map( &:to_s ).
|
73
|
+
expect( rval ).to be_a( WordNet::Synset )
|
74
|
+
expect( rval.words.map( &:to_s ) ).to include( 'carrot' )
|
92
75
|
end
|
93
76
|
|
94
77
|
it "can look up a Word by ID" do
|
95
78
|
rval = lexicon[ 21338 ]
|
96
|
-
rval.
|
97
|
-
rval.lemma.
|
79
|
+
expect( rval ).to be_a( WordNet::Word )
|
80
|
+
expect( rval.lemma ).to eq( 'carrot' )
|
98
81
|
end
|
99
82
|
|
100
83
|
it "can look up the synset for a word and a sense" do
|
101
84
|
ss = lexicon[ :boot, 3 ]
|
102
|
-
ss.
|
103
|
-
ss.definition.
|
85
|
+
expect( ss ).to be_a( WordNet::Synset )
|
86
|
+
expect( ss.definition ).to eq( 'footwear that covers the whole foot and lower leg' )
|
104
87
|
end
|
105
88
|
|
106
89
|
it "can look up all synsets for a particular word" do
|
107
90
|
sss = lexicon.lookup_synsets( :tree )
|
108
|
-
sss.
|
109
|
-
sss.all
|
91
|
+
expect( sss.size ).to eq( 7 )
|
92
|
+
expect( sss ).to all( be_a(WordNet::Synset) )
|
110
93
|
end
|
111
94
|
|
112
95
|
it "can constrain fetched synsets to a certain range of results" do
|
113
96
|
sss = lexicon.lookup_synsets( :tree, 1..4 )
|
114
|
-
sss.
|
97
|
+
expect( sss.size ).to eq( 4 )
|
115
98
|
end
|
116
99
|
|
117
100
|
it "can constrain fetched synsets to a certain (exclusive) range of results" do
|
118
101
|
sss = lexicon.lookup_synsets( :tree, 1...4 )
|
119
|
-
sss.
|
102
|
+
expect( sss.size ).to eq( 3 )
|
120
103
|
end
|
121
104
|
|
122
105
|
end
|
@@ -131,55 +114,55 @@ describe WordNet::Lexicon do
|
|
131
114
|
|
132
115
|
it "can look up a Synset by ID" do
|
133
116
|
rval = lexicon[ 101219722 ]
|
134
|
-
rval.
|
135
|
-
rval.words.map(
|
117
|
+
expect( rval ).to be_a( WordNet::Synset )
|
118
|
+
expect( rval.words.map(&:to_s) ).to include( 'carrot' )
|
136
119
|
end
|
137
120
|
|
138
121
|
it "can look up a Word by ID" do
|
139
122
|
rval = lexicon[ 21338 ]
|
140
|
-
rval.
|
141
|
-
rval.lemma.
|
123
|
+
expect( rval ).to be_a( WordNet::Word )
|
124
|
+
expect( rval.lemma ).to eq( 'carrot' )
|
142
125
|
end
|
143
126
|
|
144
127
|
it "can look up the synset for a word and a sense" do
|
145
128
|
ss = lexicon[ :boot, 3 ]
|
146
|
-
ss.
|
147
|
-
ss.definition.
|
129
|
+
expect( ss ).to be_a( WordNet::Synset )
|
130
|
+
expect( ss.definition ).to eq( 'footwear that covers the whole foot and lower leg' )
|
148
131
|
end
|
149
132
|
|
150
133
|
it "can look up a synset for a word and a substring of its definition" do
|
151
134
|
ss = lexicon[ :boot, 'kick' ]
|
152
|
-
ss.
|
153
|
-
ss.definition.
|
135
|
+
expect( ss ).to be_a( WordNet::Synset )
|
136
|
+
expect( ss.definition ).to match( /kick/i )
|
154
137
|
end
|
155
138
|
|
156
139
|
it "can look up a synset for a word and a part of speech" do
|
157
140
|
ss = lexicon[ :boot, :verb ]
|
158
|
-
ss.
|
159
|
-
ss.definition.
|
141
|
+
expect( ss ).to be_a( WordNet::Synset )
|
142
|
+
expect( ss.definition ).to match( /cause to load/i )
|
160
143
|
end
|
161
144
|
|
162
145
|
it "can look up a synset for a word and an abbreviated part of speech" do
|
163
146
|
ss = lexicon[ :boot, :n ]
|
164
|
-
ss.
|
165
|
-
ss.definition.
|
147
|
+
expect( ss ).to be_a( WordNet::Synset )
|
148
|
+
expect( ss.definition ).to match( /act of delivering/i )
|
166
149
|
end
|
167
150
|
|
168
151
|
it "can constrain fetched synsets with a Regexp match against its definition" do
|
169
152
|
sss = lexicon.lookup_synsets( :tree, /plant/ )
|
170
|
-
sss.
|
153
|
+
expect( sss.size ).to eq( 2 )
|
171
154
|
end
|
172
155
|
|
173
156
|
it "can constrain fetched synsets via lexical domain" do
|
174
157
|
sss = lexicon.lookup_synsets( :tree, 'noun.shape' )
|
175
|
-
sss.
|
176
|
-
sss.first.
|
158
|
+
expect( sss.size ).to eq( 1 )
|
159
|
+
expect( sss.first ).to eq( WordNet::Synset[ 113912260 ] )
|
177
160
|
end
|
178
161
|
|
179
162
|
it "can constrain fetched synsets via part of speech as a single-letter Symbol" do
|
180
163
|
sss = lexicon.lookup_synsets( :tree, :n )
|
181
|
-
sss.
|
182
|
-
sss.
|
164
|
+
expect( sss.size ).to eq( 3 )
|
165
|
+
expect( sss ).to include(
|
183
166
|
WordNet::Synset[ 113912260 ],
|
184
167
|
WordNet::Synset[ 111348160 ],
|
185
168
|
WordNet::Synset[ 113104059 ]
|
@@ -188,8 +171,8 @@ describe WordNet::Lexicon do
|
|
188
171
|
|
189
172
|
it "can constrain fetched synsets via part of speech as a Symbol word" do
|
190
173
|
sss = lexicon.lookup_synsets( :tree, :verb )
|
191
|
-
sss.
|
192
|
-
sss.
|
174
|
+
expect( sss.size ).to eq( 4 )
|
175
|
+
expect( sss ).to include(
|
193
176
|
WordNet::Synset[ 200319111 ],
|
194
177
|
WordNet::Synset[ 201145163 ],
|
195
178
|
WordNet::Synset[ 201616293 ],
|
@@ -198,7 +181,7 @@ describe WordNet::Lexicon do
|
|
198
181
|
end
|
199
182
|
|
200
183
|
it "includes the database adapter name in its inspect output" do
|
201
|
-
lexicon.inspect.
|
184
|
+
expect( lexicon.inspect ).to include( "postgres" )
|
202
185
|
end
|
203
186
|
|
204
187
|
end
|