wordnet 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
metadata.gz.sig
CHANGED
Binary file
|
data/.gemtest
DELETED
File without changes
|
data/examples/add-laced-boots.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
|
3
|
-
BEGIN {
|
4
|
-
require 'pathname'
|
5
|
-
|
6
|
-
basedir = Pathname.new( __FILE__ ).dirname.parent
|
7
|
-
libdir = basedir + 'lib'
|
8
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
9
|
-
}
|
10
|
-
|
11
|
-
require 'wordnet'
|
12
|
-
|
13
|
-
#
|
14
|
-
# Add a synset for laced boots
|
15
|
-
#
|
16
|
-
|
17
|
-
lex = WordNet::Lexicon.new
|
18
|
-
|
19
|
-
boot = lex[ :boot ]
|
20
|
-
laced_boot = WordNet::Synset.create( "laced boot", "n" )
|
21
|
-
tongue = lex.lookup_synsets( "tongue", "n", 6 )
|
22
|
-
|
23
|
-
laced_boot.add_hypernyms( boot )
|
24
|
-
laced_boot.add_component_meronyms( tongue )
|
25
|
-
|
26
|
-
lex.unlock {
|
27
|
-
laced_boot.write
|
28
|
-
boot.write
|
29
|
-
tongue.write
|
30
|
-
}
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
@@ -1,42 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
BEGIN {
|
4
|
-
require 'pathname'
|
5
|
-
|
6
|
-
basedir = Pathname.new( __FILE__ ).dirname.parent
|
7
|
-
libdir = basedir + 'lib'
|
8
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
9
|
-
}
|
10
|
-
|
11
|
-
require 'wordnet'
|
12
|
-
|
13
|
-
#
|
14
|
-
# Find all articles of clothing that have collars (Adapted from the synopsis
|
15
|
-
# of Lingua::Wordnet::Analysis)
|
16
|
-
#
|
17
|
-
|
18
|
-
# Create the lexicon
|
19
|
-
lex = WordNet::Lexicon.new
|
20
|
-
|
21
|
-
# Look up the clothing synset as the origin
|
22
|
-
clothing = lex[:clothing].synsets_dataset.nouns.
|
23
|
-
filter { :definition.like('%a covering%') }.first
|
24
|
-
collar = lex[:collar].synsets_dataset.nouns.
|
25
|
-
filter { :definition.like('%band that fits around the neck%') }.first
|
26
|
-
|
27
|
-
puts "Looking for instances of:",
|
28
|
-
" #{collar}",
|
29
|
-
"in the hyponyms of",
|
30
|
-
" #{clothing}",
|
31
|
-
""
|
32
|
-
|
33
|
-
# Now traverse all hyponyms of the clothing synset, and check for "collar" among
|
34
|
-
# each one's "member" meronyms, printing any we find
|
35
|
-
clothing.traverse( :hyponyms ) do |syn|
|
36
|
-
if syn.search( :member_meronyms, collar )
|
37
|
-
puts "Has a collar: #{syn}"
|
38
|
-
else
|
39
|
-
puts "Doesn't have a collar: #{syn}" if $VERBOSE
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
#
|
3
|
-
# Find all articles of clothing that have tongues (From the synopsis of
|
4
|
-
# Lingua::Wordnet::Analysis)
|
5
|
-
#
|
6
|
-
|
7
|
-
$LOAD_PATH.unshift "lib"
|
8
|
-
require "wordnet"
|
9
|
-
|
10
|
-
# Create the lexicon
|
11
|
-
lex = WordNet::Lexicon.new
|
12
|
-
|
13
|
-
# Look up the clothes synset as the origin
|
14
|
-
clothes = lex.lookup_synsets( "clothes", WordNet::Noun, 1 )
|
15
|
-
puts clothes
|
16
|
-
|
17
|
-
# Now look up the second sense of tongue (not the anatomical part)
|
18
|
-
tongue = lex.lookup_synsets( "tongue", WordNet::Noun, 7 )
|
19
|
-
puts tongue
|
20
|
-
|
21
|
-
# Now traverse all hyponyms of the clothes synset, and check for "tongue" among
|
22
|
-
# each one's meronyms. We print any that we find.
|
23
|
-
clothes.traverse( :hyponyms ) do |syn,depth|
|
24
|
-
if syn.search( :meronyms, tongue )
|
25
|
-
puts "Has a tongue: #{syn}"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
data/examples/distance.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
#
|
3
|
-
# Find the distance between the first senses of two nouns
|
4
|
-
#
|
5
|
-
|
6
|
-
$LOAD_PATH.unshift "lib"
|
7
|
-
require "wordnet"
|
8
|
-
|
9
|
-
raise RuntimeError, "You must specify two nouns." if ARGV.length < 2
|
10
|
-
|
11
|
-
# Create the lexicon
|
12
|
-
lex = WordNet::Lexicon.new
|
13
|
-
|
14
|
-
# Look up the synsets for the two words
|
15
|
-
word1 = lex.lookup_synsets( ARGV[0], WordNet::Noun, 1 )
|
16
|
-
unless word1
|
17
|
-
puts "Couldn't find a synset for #{ARGV[0]}."
|
18
|
-
exit
|
19
|
-
end
|
20
|
-
word2 = lex.lookup_synsets( ARGV[1], WordNet::Noun, 1 )
|
21
|
-
unless word2
|
22
|
-
puts "Couldn't find a synset for #{ARGV[1]}."
|
23
|
-
exit
|
24
|
-
end
|
25
|
-
|
26
|
-
# Analyze the distance
|
27
|
-
distance = word1.distance( :hypernyms, word2 )
|
28
|
-
|
29
|
-
# If we got a distance, display it.
|
30
|
-
if distance
|
31
|
-
puts "The hypernym distance between #{word1.words[0]} and #{word2.words[0]} is: #{distance}"
|
32
|
-
|
33
|
-
# If we didn't get a distance, the second word isn't a hypernym of the first
|
34
|
-
else
|
35
|
-
puts "#{word1.words[0]} is not a kind of #{word2.words[0]}, apparently."
|
36
|
-
end
|
37
|
-
|
data/examples/domainTree.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
#
|
3
|
-
# Find all the domains of all senses of a given noun, and display them in a heirarchy.
|
4
|
-
#
|
5
|
-
|
6
|
-
$LOAD_PATH.unshift "lib"
|
7
|
-
require "wordnet"
|
8
|
-
|
9
|
-
raise RuntimeError, "No word specified." if ARGV.empty?
|
10
|
-
|
11
|
-
# Create the lexicon
|
12
|
-
lex = WordNet::Lexicon.new
|
13
|
-
|
14
|
-
# Look up the synsets for the specified word
|
15
|
-
origins = lex.lookup_synsets( ARGV[0], WordNet::Noun )
|
16
|
-
|
17
|
-
# Use the analyzer to traverse domains of the synset, adding a string for each
|
18
|
-
# one with indentation for the level
|
19
|
-
origins.each_index {|i|
|
20
|
-
treeComponents = []
|
21
|
-
origins[i].traverse( :domains ) {|syn,depth|
|
22
|
-
treeComponents << " #{' ' * depth}#{syn.words[0]} -- #{syn.gloss.split(/;/)[0]}"
|
23
|
-
}
|
24
|
-
|
25
|
-
puts "\nDomain tree for sense #{i} of #{ARGV[0]}:\n" + treeComponents.join( "\n" )
|
26
|
-
puts "Tree has #{treeComponents.length} synsets."
|
27
|
-
}
|
data/examples/holonymTree.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
#
|
3
|
-
# Find all the holonyms of all senses of a given noun, and display them in a heirarchy.
|
4
|
-
#
|
5
|
-
|
6
|
-
$LOAD_PATH.unshift "lib"
|
7
|
-
require "wordnet"
|
8
|
-
|
9
|
-
raise RuntimeError, "No word specified." if ARGV.empty?
|
10
|
-
|
11
|
-
# Create the lexicon
|
12
|
-
lex = WordNet::Lexicon.new
|
13
|
-
|
14
|
-
# Look up the synsets for the specified word
|
15
|
-
origins = lex.lookup_synsets( ARGV[0], WordNet::Noun )
|
16
|
-
|
17
|
-
# Use the analyzer to traverse holonyms of the synset, adding a string for each
|
18
|
-
# one with indentation for the level
|
19
|
-
origins.each_index {|i|
|
20
|
-
treeComponents = []
|
21
|
-
origins[i].traverse( :holonyms ) {|syn,depth|
|
22
|
-
treeComponents << " #{' ' * depth}#{syn.words[0]} -- #{syn.gloss.split(/;/)[0]}"
|
23
|
-
}
|
24
|
-
|
25
|
-
puts "\nHolonym tree for sense #{i} of #{ARGV[0]}:\n" + treeComponents.join( "\n" )
|
26
|
-
puts "Tree has #{treeComponents.length} synsets."
|
27
|
-
}
|
data/examples/hypernymTree.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
#
|
3
|
-
# Find all the hypernyms of all senses of a given noun and display them in a
|
4
|
-
# heirarchy
|
5
|
-
#
|
6
|
-
|
7
|
-
$LOAD_PATH.unshift "lib"
|
8
|
-
require 'wordnet'
|
9
|
-
|
10
|
-
raise RuntimeError, "No word specified." if ARGV.empty?
|
11
|
-
|
12
|
-
# Create the lexicon
|
13
|
-
lex = WordNet::Lexicon.new
|
14
|
-
|
15
|
-
# Look up the synsets for the specified word
|
16
|
-
origins = lex.lookup_synsets( ARGV[0], WordNet::Noun )
|
17
|
-
|
18
|
-
# Use the analyzer to traverse hypernyms of the synset, adding a string for each
|
19
|
-
# one with indentation for the level
|
20
|
-
origins.each_index {|i|
|
21
|
-
treeComponents = []
|
22
|
-
origins[i].traverse( :hypernyms ) {|syn,depth|
|
23
|
-
treeComponents << " #{' ' * depth}#{syn.words[0]} -- #{syn.gloss.split(/;/)[0]}"
|
24
|
-
}
|
25
|
-
|
26
|
-
puts "\nHypernym tree for sense #{i} of #{ARGV[0]}:\n" + treeComponents.join( "\n" )
|
27
|
-
puts "Tree has #{treeComponents.length} synsets."
|
28
|
-
}
|
data/examples/hyponymTree.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
#
|
3
|
-
# Find all the hyponyms of all senses of a given noun and display them in a
|
4
|
-
# heirarchy
|
5
|
-
#
|
6
|
-
|
7
|
-
$LOAD_PATH.unshift "lib"
|
8
|
-
require 'wordnet'
|
9
|
-
|
10
|
-
raise RuntimeError, "No word specified." if ARGV.empty?
|
11
|
-
|
12
|
-
# Create the lexicon
|
13
|
-
lex = WordNet::Lexicon.new
|
14
|
-
|
15
|
-
# Look up the synsets for the specified word
|
16
|
-
origins = lex.lookup_synsets( ARGV[0], WordNet::Noun )
|
17
|
-
|
18
|
-
# Use the analyzer to traverse hyponyms of the synset, adding a string for each
|
19
|
-
# one with indentation for the level
|
20
|
-
origins.each_index {|i|
|
21
|
-
treeComponents = []
|
22
|
-
origins[i].traverse( :hyponyms ) {|syn,depth|
|
23
|
-
treeComponents << " #{' ' * depth}#{syn.words[0]} -- #{syn.gloss.split(/;/)[0]}"
|
24
|
-
}
|
25
|
-
|
26
|
-
puts "\nHyponym tree for sense #{i} of #{ARGV[0]}:\n" + treeComponents.join( "\n" )
|
27
|
-
puts "Tree has #{treeComponents.length} synsets."
|
28
|
-
}
|
data/examples/memberTree.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
#
|
3
|
-
# Find all the members of all senses of a given noun, and display them in a heirarchy.
|
4
|
-
#
|
5
|
-
|
6
|
-
$LOAD_PATH.unshift "lib"
|
7
|
-
require "wordnet"
|
8
|
-
|
9
|
-
raise RuntimeError, "No word specified." if ARGV.empty?
|
10
|
-
|
11
|
-
# Create the lexicon
|
12
|
-
lex = WordNet::Lexicon.new
|
13
|
-
|
14
|
-
# Look up the synsets for the specified word
|
15
|
-
origins = lex.lookup_synsets( ARGV[0], WordNet::Noun )
|
16
|
-
|
17
|
-
# Use the analyzer to traverse members of the synset, adding a string for each
|
18
|
-
# one with indentation for the level
|
19
|
-
origins.each_index {|i|
|
20
|
-
treeComponents = []
|
21
|
-
origins[i].traverse( :members ) {|syn,depth|
|
22
|
-
treeComponents << " #{' ' * depth}#{syn.words[0]} -- #{syn.gloss.split(/;/)[0]}"
|
23
|
-
}
|
24
|
-
|
25
|
-
puts "\nMember tree for sense #{i} of #{ARGV[0]}:\n" + treeComponents.join( "\n" )
|
26
|
-
puts "Tree has #{treeComponents.length} synsets."
|
27
|
-
}
|
data/examples/meronymTree.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby -w
|
2
|
-
#
|
3
|
-
# Find all meronyms (components) of each sense of a given noun and display
|
4
|
-
# them heirarchically
|
5
|
-
#
|
6
|
-
|
7
|
-
$LOAD_PATH.unshift "lib"
|
8
|
-
require 'wordnet'
|
9
|
-
|
10
|
-
raise RuntimeError, "No word specified." if ARGV.empty?
|
11
|
-
|
12
|
-
# Create the lexicon
|
13
|
-
lex = WordNet::Lexicon.new
|
14
|
-
|
15
|
-
# Look up the synsets for the specified word
|
16
|
-
origins = lex.lookup_synsets( ARGV[0], WordNet::Noun )
|
17
|
-
|
18
|
-
# Use the analyzer to traverse meronyms of the synset, adding a string for each
|
19
|
-
# one with indentation for the level
|
20
|
-
origins.each_index {|i|
|
21
|
-
treeComponents = []
|
22
|
-
origins[i].traverse( :meronyms ) {|syn,depth|
|
23
|
-
treeComponents << " #{' ' * depth}#{syn.words[0]} -- #{syn.gloss.split(/;/)[0]}"
|
24
|
-
}
|
25
|
-
|
26
|
-
puts "\nMeronym tree for sense #{i} of #{ARGV[0]}:\n" + treeComponents.join( "\n" )
|
27
|
-
puts "Tree has #{treeComponents.length} synsets."
|
28
|
-
}
|
29
|
-
|
data/spec/lib/helpers.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
# coding: utf-8
|
3
|
-
|
4
|
-
BEGIN {
|
5
|
-
require 'pathname'
|
6
|
-
basedir = Pathname.new( __FILE__ ).dirname.parent
|
7
|
-
|
8
|
-
libdir = basedir + "lib"
|
9
|
-
|
10
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
11
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
12
|
-
}
|
13
|
-
|
14
|
-
# SimpleCov test coverage reporting; enable this using the :coverage rake task
|
15
|
-
if ENV['COVERAGE']
|
16
|
-
$stderr.puts "\n\n>>> Enabling coverage report.\n\n"
|
17
|
-
require 'simplecov'
|
18
|
-
SimpleCov.start do
|
19
|
-
add_filter 'spec'
|
20
|
-
add_group "Needing tests" do |file|
|
21
|
-
file.covered_percent < 90
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
require 'rspec'
|
27
|
-
require 'loggability/spechelpers'
|
28
|
-
require 'wordnet'
|
29
|
-
|
30
|
-
|
31
|
-
### RSpec helper functions.
|
32
|
-
module WordNet::SpecHelpers
|
33
|
-
|
34
|
-
###############
|
35
|
-
module_function
|
36
|
-
###############
|
37
|
-
|
38
|
-
### Make an easily-comparable version vector out of +ver+ and return it.
|
39
|
-
def vvec( ver )
|
40
|
-
return ver.split('.').collect {|char| char.to_i }.pack('N*')
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
### Make a WordNet::Directory that will use the given +conn+ object as its
|
45
|
-
### LDAP connection. Also pre-loads the schema object and fixtures some other
|
46
|
-
### external data.
|
47
|
-
def get_fixtured_directory( conn )
|
48
|
-
LDAP::SSLConn.stub( :new ).and_return( @conn )
|
49
|
-
conn.stub( :root_dse ).and_return( nil )
|
50
|
-
directory = WordNet.directory( TEST_LDAPURI )
|
51
|
-
directory.stub( :schema ).and_return( SCHEMA )
|
52
|
-
|
53
|
-
return directory
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
### Mock with Rspec
|
60
|
-
RSpec.configure do |c|
|
61
|
-
c.mock_with :rspec
|
62
|
-
c.include( WordNet::SpecHelpers )
|
63
|
-
c.include( Loggability::SpecHelpers )
|
64
|
-
|
65
|
-
c.treat_symbols_as_metadata_keys_with_true_values = true
|
66
|
-
|
67
|
-
if Gem::Specification.find_all_by_name( 'pg' ).empty?
|
68
|
-
c.filter_run_excluding( :requires_pg )
|
69
|
-
end
|
70
|
-
|
71
|
-
begin
|
72
|
-
uri = WordNet::Lexicon.default_db_uri
|
73
|
-
WordNet.log.info "Database tests will use: #{uri}"
|
74
|
-
rescue WordNet::LexiconError
|
75
|
-
c.filter_run_excluding( :requires_database )
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# vim: set nosta noet ts=4 sw=4:
|
80
|
-
|
data/spec/linguawordnet.tests.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
#!/usr/bin/ruby
|
2
|
-
|
3
|
-
require "wntestcase"
|
4
|
-
|
5
|
-
class LexiconTests < WordNet::TestCase
|
6
|
-
|
7
|
-
OldBaseballOffset = '00466621%n'
|
8
|
-
BaseballOffset = '00471613%n'
|
9
|
-
|
10
|
-
def test_perl_tests
|
11
|
-
synset = nil
|
12
|
-
synset2 = nil
|
13
|
-
|
14
|
-
begin
|
15
|
-
synset = @lexicon.lookup_synsets_by_key( BaseballOffset )
|
16
|
-
rescue WordNet::LookupError
|
17
|
-
synset = @lexicon.lookup_synsets_by_key( OldBaseballOffset )
|
18
|
-
end
|
19
|
-
|
20
|
-
assert_instance_of WordNet::Synset, synset
|
21
|
-
|
22
|
-
words = ''
|
23
|
-
synset.hyponyms.each do |bb_synset|
|
24
|
-
bb_synset.words += ["ballser"]
|
25
|
-
bb_synset.words.each {|word| words += "#{word}, "}
|
26
|
-
end
|
27
|
-
assert_match( /hardball/, words )
|
28
|
-
|
29
|
-
words = ''
|
30
|
-
synset2 = @lexicon.lookup_synsets( "travel", WordNet::Verb, 2 )
|
31
|
-
synset2.words.each {|word| words += "#{word}, "}
|
32
|
-
assert_match( /journey/, words )
|
33
|
-
|
34
|
-
assert_equal 4, @lexicon.familiarity( "boy", WordNet::Noun )
|
35
|
-
assert_equal "blue", @lexicon.morph( "bluest", WordNet::Adjective )
|
36
|
-
assert_match( /baseball/, "#{synset}" )
|
37
|
-
end
|
38
|
-
end
|