wordnet 0.0.5
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.
- data/ChangeLog +720 -0
- data/LICENSE +27 -0
- data/README +93 -0
- data/Rakefile +291 -0
- data/Rakefile.local +46 -0
- data/convertdb.rb +417 -0
- data/examples/addLacedBoots.rb +27 -0
- data/examples/clothesWithCollars.rb +36 -0
- data/examples/clothesWithTongues.rb +28 -0
- data/examples/distance.rb +37 -0
- data/examples/domainTree.rb +27 -0
- data/examples/gcs.rb +54 -0
- data/examples/holonymTree.rb +27 -0
- data/examples/hypernymTree.rb +28 -0
- data/examples/hyponymTree.rb +28 -0
- data/examples/memberTree.rb +27 -0
- data/examples/meronymTree.rb +29 -0
- data/lib/wordnet.rb +87 -0
- data/lib/wordnet/constants.rb +301 -0
- data/lib/wordnet/lexicon.rb +430 -0
- data/lib/wordnet/synset.rb +908 -0
- data/rake/dependencies.rb +76 -0
- data/rake/helpers.rb +384 -0
- data/rake/manual.rb +755 -0
- data/rake/packaging.rb +112 -0
- data/rake/publishing.rb +303 -0
- data/rake/rdoc.rb +35 -0
- data/rake/style.rb +62 -0
- data/rake/svn.rb +469 -0
- data/rake/testing.rb +192 -0
- data/rake/verifytask.rb +64 -0
- data/spec/lib/helpers.rb +155 -0
- data/spec/wordnet/lexicon_spec.rb +248 -0
- data/spec/wordnet/synset_spec.rb +288 -0
- data/utils.rb +838 -0
- metadata +216 -0
@@ -0,0 +1,28 @@
|
|
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
|
+
|
@@ -0,0 +1,37 @@
|
|
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
|
+
|
@@ -0,0 +1,27 @@
|
|
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/gcs.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
#
|
3
|
+
# Find least general hypernymial synsets between all noun senses of two words.
|
4
|
+
#
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift "lib"
|
7
|
+
require "wordnet"
|
8
|
+
|
9
|
+
raise RuntimeError, "You must specify two words." if ARGV.length != 2
|
10
|
+
|
11
|
+
# Create the lexicon
|
12
|
+
lex = WordNet::Lexicon.new
|
13
|
+
|
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
|
+
|
18
|
+
def debugMsg( message )
|
19
|
+
return unless $DEBUG
|
20
|
+
$stderr.puts message
|
21
|
+
end
|
22
|
+
|
23
|
+
# Use the analyzer to traverse hypernyms of the synset, adding a string for each
|
24
|
+
# one with indentation for the level
|
25
|
+
word1Syns.each {|syn|
|
26
|
+
debugMsg( ">>> Searching with #{syn.wordlist} as the origin." )
|
27
|
+
|
28
|
+
word2Syns.each {|secondSyn|
|
29
|
+
debugMsg( " Comparing #{secondSyn.wordlist} to the origin." )
|
30
|
+
|
31
|
+
# The intersection of the two syns is the most-specific hypernym they
|
32
|
+
# 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
|
48
|
+
else
|
49
|
+
debugMsg( " No synsets in common." )
|
50
|
+
end
|
51
|
+
}
|
52
|
+
|
53
|
+
debugMsg( " done with #{syn.wordlist}" )
|
54
|
+
}
|
@@ -0,0 +1,27 @@
|
|
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
|
+
}
|
@@ -0,0 +1,28 @@
|
|
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
|
+
}
|
@@ -0,0 +1,28 @@
|
|
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
|
+
}
|
@@ -0,0 +1,27 @@
|
|
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
|
+
}
|
@@ -0,0 +1,29 @@
|
|
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/lib/wordnet.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
#
|
2
|
+
# WordNet - A Ruby interface to the WordNet lexical database
|
3
|
+
#
|
4
|
+
# == Synopsis
|
5
|
+
#
|
6
|
+
# require "WordNet"
|
7
|
+
#
|
8
|
+
# # Create a new lexicon object
|
9
|
+
# lex = WordNet::Lexicon::new
|
10
|
+
#
|
11
|
+
# # Look up the synsets for "language" and "computer program"
|
12
|
+
# languageSynset = lex.lookup_synsets( "language", WordNet::Noun, 3 )
|
13
|
+
# programSynset = lex.lookup_synsets( "program", WordNet::Noun, 3 )
|
14
|
+
#
|
15
|
+
# # Create a new synset for programming languages, set its gloss, link it to its
|
16
|
+
# # hypernym and holonym, and save everything to the database.
|
17
|
+
# progLangSynset = lex.create_synset( "programming language", WordNet::Noun )
|
18
|
+
# progLangSynset.gloss = "a system of human-readable symbols and words "\
|
19
|
+
# "for encoding instructions for a computer"
|
20
|
+
# progLangSynset.hypernyms += languageSynset
|
21
|
+
# languageSynset.hyponyms += progLangSynset
|
22
|
+
# progLangSynset.holonyms += programSynset
|
23
|
+
# programSynset.stuff_meronyms += progLangSynset
|
24
|
+
# [ progLangSynset, programSynset, languageSynset ].each do |synset|
|
25
|
+
# synset.store
|
26
|
+
# end
|
27
|
+
#
|
28
|
+
# # Create a new synset for Ruby, link it, and save it
|
29
|
+
# rubySynset = lex.create_synset( "Ruby", Wordnet::Noun )
|
30
|
+
# rubySynset.gloss = "an interpreted scripting language for quick and easy object-oriented programming"
|
31
|
+
# rubySynset.hypernyms += languageSyn ; languageSynset.hyponyms += rubySyn
|
32
|
+
# rubySynset.write ; languageSynset.write
|
33
|
+
#
|
34
|
+
# == Description
|
35
|
+
#
|
36
|
+
# This is a Ruby interface to the WordNet lexical database. It's mostly a port
|
37
|
+
# of Dan Brian's Lingua::Wordnet Perl module, modified a bit to be more
|
38
|
+
# Ruby-ish.
|
39
|
+
#
|
40
|
+
# == Author
|
41
|
+
#
|
42
|
+
# The Lingua::Wordnet module by Dan Brian, on which this code is based, falls under
|
43
|
+
# the following license:
|
44
|
+
#
|
45
|
+
# Copyright 1999,2000,2001 by Dan Brian.
|
46
|
+
#
|
47
|
+
# This program is free software; you can redistribute it and/or modify
|
48
|
+
# it under the same terms as Perl itself.
|
49
|
+
#
|
50
|
+
# Written by Michael Granger <ged@FaerieMUD.org>
|
51
|
+
#
|
52
|
+
# Copyright (c) 2002,2003,2005 The FaerieMUD Consortium. All rights reserved.
|
53
|
+
#
|
54
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
55
|
+
# software under the terms of the Perl Artistic License. (See
|
56
|
+
# http://language.perl.com/misc/Artistic.html)
|
57
|
+
#
|
58
|
+
# == Version
|
59
|
+
#
|
60
|
+
# $Id: wordnet.rb 90 2008-07-09 23:02:53Z deveiant $
|
61
|
+
#
|
62
|
+
|
63
|
+
# Try to provide underbarred alternatives for camelCased methods. Requires the
|
64
|
+
# 'CrossCase' module.
|
65
|
+
begin
|
66
|
+
require 'crosscase'
|
67
|
+
rescue LoadError
|
68
|
+
end
|
69
|
+
|
70
|
+
### The main namespace for WordNet classes
|
71
|
+
module WordNet
|
72
|
+
|
73
|
+
# Revision tag
|
74
|
+
SvnRev = %q$Rev: 90 $
|
75
|
+
|
76
|
+
# Id tag
|
77
|
+
SvnId = %q$Id: wordnet.rb 90 2008-07-09 23:02:53Z deveiant $
|
78
|
+
|
79
|
+
# Release version
|
80
|
+
VERSION = '0.0.5'
|
81
|
+
|
82
|
+
require 'wordnet/constants'
|
83
|
+
require 'wordnet/lexicon'
|
84
|
+
require 'wordnet/synset'
|
85
|
+
|
86
|
+
end # module WordNet
|
87
|
+
|
@@ -0,0 +1,301 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
#
|
3
|
+
# This is a module containing constants used in the WordNet interface for
|
4
|
+
# Ruby. They are contained in a module to facilitate their easy inclusion in
|
5
|
+
# other namespaces. All constants in this module are also contained in the
|
6
|
+
# WordNet namespace itself.
|
7
|
+
#
|
8
|
+
# E.g.,
|
9
|
+
#
|
10
|
+
# WordNet::Adjective == WordNet::Constants::Adjective
|
11
|
+
#
|
12
|
+
# If you do:
|
13
|
+
# include WordNet::Constants
|
14
|
+
#
|
15
|
+
# then:
|
16
|
+
# Adjective == WordNet::Adjective
|
17
|
+
#
|
18
|
+
# == Synopsis
|
19
|
+
#
|
20
|
+
# require 'wordnet'
|
21
|
+
# include WordNet::Constants
|
22
|
+
#
|
23
|
+
# lex = WordNet::Lexicon::new
|
24
|
+
# origins = lex.lookup_synsets( "shoe", Noun )
|
25
|
+
#
|
26
|
+
# == Authors
|
27
|
+
#
|
28
|
+
# * Michael Granger <ged@FaerieMUD.org>
|
29
|
+
#
|
30
|
+
# == Copyright
|
31
|
+
#
|
32
|
+
# Copyright (c) 2003-2008 The FaerieMUD Consortium. All rights reserved.
|
33
|
+
#
|
34
|
+
# This module is free software. You may use, modify, and/or redistribute this
|
35
|
+
# software under the terms of the Perl Artistic License. (See
|
36
|
+
# http://language.perl.com/misc/Artistic.html)
|
37
|
+
#
|
38
|
+
# == Version
|
39
|
+
#
|
40
|
+
# $Id: constants.rb 90 2008-07-09 23:02:53Z deveiant $
|
41
|
+
#
|
42
|
+
module WordNet
|
43
|
+
|
44
|
+
### Constant-container module
|
45
|
+
module Constants
|
46
|
+
|
47
|
+
# Synset syntactic-category names -> indicators
|
48
|
+
SYNTACTIC_CATEGORIES = {
|
49
|
+
:noun => "n",
|
50
|
+
:verb => "v",
|
51
|
+
:adjective => "a",
|
52
|
+
:adverb => "r",
|
53
|
+
:other => "s",
|
54
|
+
}
|
55
|
+
# Syntactic-category indicators -> names
|
56
|
+
SYNTACTIC_SYMBOLS = SYNTACTIC_CATEGORIES.invert
|
57
|
+
|
58
|
+
# Map the categories into their own constants (eg., Noun)
|
59
|
+
SYNTACTIC_CATEGORIES.each do |sym,val|
|
60
|
+
cname = sym.to_s.capitalize
|
61
|
+
const_set( cname, val )
|
62
|
+
end
|
63
|
+
|
64
|
+
# Information about pointer types is contained in the wninput(5WN)
|
65
|
+
# manpage.
|
66
|
+
|
67
|
+
# Synset pointer typenames -> indicators
|
68
|
+
POINTER_TYPES = {
|
69
|
+
:antonym => '!',
|
70
|
+
:hypernym => '@',
|
71
|
+
:entailment => '*',
|
72
|
+
:hyponym => '~',
|
73
|
+
:meronym => '%',
|
74
|
+
:holonym => '#',
|
75
|
+
:cause => '>',
|
76
|
+
:verb_group => %{$},
|
77
|
+
:similar_to => '&',
|
78
|
+
:participle => '<',
|
79
|
+
:pertainym => '\\',
|
80
|
+
:attribute => '=',
|
81
|
+
:derived_from => '\\',
|
82
|
+
:see_also => '^',
|
83
|
+
:derivation => '+',
|
84
|
+
:domain => ';',
|
85
|
+
:member => '-',
|
86
|
+
}
|
87
|
+
|
88
|
+
# Synset pointer indicator -> typename
|
89
|
+
POINTER_SYMBOLS = POINTER_TYPES.invert
|
90
|
+
|
91
|
+
# Map the pointer types into their own symbols (eg., :verb_group => VerbGroup)
|
92
|
+
POINTER_TYPES.each do |sym,val|
|
93
|
+
cname = sym.to_s.gsub( /(?:^|_)(.)/ ) { $1.upcase }
|
94
|
+
const_set( cname, val )
|
95
|
+
end
|
96
|
+
|
97
|
+
# Hypernym synset pointer types
|
98
|
+
HYPERNYM_TYPES = {
|
99
|
+
nil => '@', # Install non-subtype methods, too
|
100
|
+
:instance => '@i',
|
101
|
+
}
|
102
|
+
|
103
|
+
# Hypernym indicator -> type map
|
104
|
+
HYPERNYM_SYMBOLS = HYPERNYM_TYPES.invert
|
105
|
+
|
106
|
+
# Hyponym synset pointer types
|
107
|
+
HYPONYM_TYPES = {
|
108
|
+
nil => '~', # Install non-subtype methods, too
|
109
|
+
:instance => '~i',
|
110
|
+
}
|
111
|
+
|
112
|
+
# Hyponym indicator -> type map
|
113
|
+
HYPONYM_SYMBOLS = HYPONYM_TYPES.invert
|
114
|
+
|
115
|
+
# Meronym synset pointer types
|
116
|
+
MERONYM_TYPES = {
|
117
|
+
:member => '%m',
|
118
|
+
:stuff => '%s',
|
119
|
+
:portion => '%o',
|
120
|
+
:component => '%p',
|
121
|
+
:feature => '%f',
|
122
|
+
:phase => '%a',
|
123
|
+
:place => '%l',
|
124
|
+
}
|
125
|
+
|
126
|
+
# Meronym indicator -> type map
|
127
|
+
MERONYM_SYMBOLS = MERONYM_TYPES.invert
|
128
|
+
|
129
|
+
# Map the meronym types into their own constants (eg., MemberMeronym)
|
130
|
+
MERONYM_TYPES.each do |sym,val|
|
131
|
+
cname = sym.to_s.capitalize + "Meronym"
|
132
|
+
const_set( cname, val )
|
133
|
+
end
|
134
|
+
|
135
|
+
# Holonym synset pointer types
|
136
|
+
HOLONYM_TYPES = {
|
137
|
+
:member => '#m',
|
138
|
+
:stuff => '#s',
|
139
|
+
:portion => '#o',
|
140
|
+
:component => '#p',
|
141
|
+
:feature => '#f',
|
142
|
+
:phase => '#a',
|
143
|
+
:place => '#l',
|
144
|
+
}
|
145
|
+
|
146
|
+
# Holonym indicator -> type map
|
147
|
+
HOLONYM_SYMBOLS = HOLONYM_TYPES.invert
|
148
|
+
|
149
|
+
# Map the holonym types into their own constants (eg., MemberHolonym)
|
150
|
+
HOLONYM_TYPES.each do |sym,val|
|
151
|
+
cname = sym.to_s.capitalize + "Holonym"
|
152
|
+
const_set( cname, val )
|
153
|
+
end
|
154
|
+
|
155
|
+
# Domain synset pointer types
|
156
|
+
DOMAIN_TYPES = {
|
157
|
+
:category => ';c',
|
158
|
+
:region => ';r',
|
159
|
+
:usage => ';u',
|
160
|
+
}
|
161
|
+
|
162
|
+
# Domain indicator -> type map
|
163
|
+
DomainSymbols = DOMAIN_TYPES.invert
|
164
|
+
|
165
|
+
# Map the domain types into their own constants (eg., CategoryDomain)
|
166
|
+
DOMAIN_TYPES.each do |sym,val|
|
167
|
+
cname = sym.to_s.capitalize + "Domain"
|
168
|
+
const_set( cname, val )
|
169
|
+
end
|
170
|
+
|
171
|
+
# Member synset pointer types
|
172
|
+
MEMBER_TYPES = {
|
173
|
+
:category => '-c',
|
174
|
+
:region => '-r',
|
175
|
+
:usage => '-u',
|
176
|
+
}
|
177
|
+
|
178
|
+
# Member indicator -> type map
|
179
|
+
MEMBER_SYMBOLS = MEMBER_TYPES.invert
|
180
|
+
|
181
|
+
# Map the member types into their own constants (eg., CategoryMember)
|
182
|
+
MEMBER_TYPES.each do |sym,val|
|
183
|
+
cname = sym.to_s.capitalize + "Member"
|
184
|
+
const_set( cname, val )
|
185
|
+
end
|
186
|
+
|
187
|
+
# Map of primary types to maps of their subtypes
|
188
|
+
POINTER_SUBTYPES = {
|
189
|
+
:hyponym => HYPONYM_TYPES,
|
190
|
+
:hypernym => HYPERNYM_TYPES,
|
191
|
+
:meronym => MERONYM_TYPES,
|
192
|
+
:holonym => HOLONYM_TYPES,
|
193
|
+
:member => MEMBER_TYPES,
|
194
|
+
:domain => DOMAIN_TYPES,
|
195
|
+
}
|
196
|
+
|
197
|
+
|
198
|
+
# Record-part delimiter
|
199
|
+
DELIM = '||'
|
200
|
+
DELIM_RE = Regexp::new( Regexp::quote(DELIM) )
|
201
|
+
|
202
|
+
# Record-subpart delimiter
|
203
|
+
SUB_DELIM = '|'
|
204
|
+
SUB_DELIM_RE = Regexp::new( Regexp::quote(SUB_DELIM) )
|
205
|
+
|
206
|
+
# Lexicographer file index -- from lexnames(5WN)
|
207
|
+
LEXFILES = [
|
208
|
+
"adj.all",
|
209
|
+
"adj.pert",
|
210
|
+
"adv.all",
|
211
|
+
"noun.Tops",
|
212
|
+
"noun.act",
|
213
|
+
"noun.animal",
|
214
|
+
"noun.artifact",
|
215
|
+
"noun.attribute",
|
216
|
+
"noun.body",
|
217
|
+
"noun.cognition",
|
218
|
+
"noun.communication",
|
219
|
+
"noun.event",
|
220
|
+
"noun.feeling",
|
221
|
+
"noun.food",
|
222
|
+
"noun.group",
|
223
|
+
"noun.location",
|
224
|
+
"noun.motive",
|
225
|
+
"noun.object",
|
226
|
+
"noun.person",
|
227
|
+
"noun.phenomenon",
|
228
|
+
"noun.plant",
|
229
|
+
"noun.possession",
|
230
|
+
"noun.process",
|
231
|
+
"noun.quantity",
|
232
|
+
"noun.relation",
|
233
|
+
"noun.shape",
|
234
|
+
"noun.state",
|
235
|
+
"noun.substance",
|
236
|
+
"noun.time",
|
237
|
+
"verb.body",
|
238
|
+
"verb.change",
|
239
|
+
"verb.cognition",
|
240
|
+
"verb.communication",
|
241
|
+
"verb.competition",
|
242
|
+
"verb.consumption",
|
243
|
+
"verb.contact",
|
244
|
+
"verb.creation",
|
245
|
+
"verb.emotion",
|
246
|
+
"verb.motion",
|
247
|
+
"verb.perception",
|
248
|
+
"verb.possession",
|
249
|
+
"verb.social",
|
250
|
+
"verb.stative",
|
251
|
+
"verb.weather",
|
252
|
+
"adj.ppl"
|
253
|
+
]
|
254
|
+
|
255
|
+
# Verb sentences (?) -- used in building verb frames.
|
256
|
+
VERB_SENTS = [
|
257
|
+
"",
|
258
|
+
"Something ----s",
|
259
|
+
"Somebody ----s",
|
260
|
+
"It is ----ing",
|
261
|
+
"Something is ----ing PP",
|
262
|
+
"Something ----s something Adjective/Noun",
|
263
|
+
"Something ----s Adjective/Noun",
|
264
|
+
"Somebody ----s Adjective",
|
265
|
+
"Somebody ----s something",
|
266
|
+
"Somebody ----s somebody",
|
267
|
+
"Something ----s somebody",
|
268
|
+
"Something ----s something",
|
269
|
+
"Something ----s to somebody",
|
270
|
+
"Somebody ----s on something",
|
271
|
+
"Somebody ----s somebody something",
|
272
|
+
"Somebody ----s something to somebody",
|
273
|
+
"Somebody ----s something from somebody",
|
274
|
+
"Somebody ----s somebody with something",
|
275
|
+
"Somebody ----s somebody of something",
|
276
|
+
"Somebody ----s something on somebody",
|
277
|
+
"Somebody ----s somebody PP",
|
278
|
+
"Somebody ----s something PP",
|
279
|
+
"Somebody ----s PP",
|
280
|
+
"Somebody's (body part) ----s",
|
281
|
+
"Somebody ----s somebody to INFINITIVE",
|
282
|
+
"Somebody ----s somebody INFINITIVE",
|
283
|
+
"Somebody ----s that CLAUSE",
|
284
|
+
"Somebody ----s to somebody",
|
285
|
+
"Somebody ----s to INFINITIVE",
|
286
|
+
"Somebody ----s whether INFINITIVE",
|
287
|
+
"Somebody ----s somebody into V-ing something",
|
288
|
+
"Somebody ----s something with something",
|
289
|
+
"Somebody ----s INFINITIVE",
|
290
|
+
"Somebody ----s VERB-ing",
|
291
|
+
"It ----s that CLAUSE",
|
292
|
+
"Something ----s INFINITIVE"
|
293
|
+
]
|
294
|
+
|
295
|
+
|
296
|
+
end # module Constants
|
297
|
+
|
298
|
+
# Make the constants available under the WordNet namespace, too.
|
299
|
+
include Constants
|
300
|
+
|
301
|
+
end # module WordNet
|