wordnet 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data/History.md +33 -0
- data/README.md +140 -1
- data/lib/wordnet/constants.rb +0 -1
- data/lib/wordnet/lexicallink.rb +0 -1
- data/lib/wordnet/lexicon.rb +7 -6
- data/lib/wordnet/model.rb +0 -2
- data/lib/wordnet/morph.rb +12 -1
- data/lib/wordnet/semanticlink.rb +8 -1
- data/lib/wordnet/sense.rb +44 -1
- data/lib/wordnet/sumoterm.rb +0 -1
- data/lib/wordnet/synset.rb +1 -2
- data/lib/wordnet/word.rb +0 -1
- data/lib/wordnet.rb +1 -2
- data/spec/helpers.rb +17 -5
- data.tar.gz.sig +0 -0
- metadata +63 -138
- metadata.gz.sig +0 -0
- data/.gems +0 -6
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.simplecov +0 -8
- data/ChangeLog +0 -829
- data/Gemfile +0 -2
- data/History.rdoc +0 -21
- data/LICENSE +0 -27
- data/Manifest.txt +0 -37
- data/README.rdoc +0 -101
- data/Rakefile +0 -102
- data/TODO +0 -9
- data/certs/ged.pem +0 -26
- data/examples/gcs.rb +0 -44
- data/examples/hypernym_tree.rb +0 -34
- data/wordnet.gemspec +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6a3f4db4815bfad5f10d2c684bb66466414b27c5fdb186a53579ca71d2c279f9
|
4
|
+
data.tar.gz: 939d0eb8a138ef9802105829d31ee2078a3dce010186a1606d7456aef6292f7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ef75970224d87c5946815902d168d344fed6321598218d0eec4a6a972ab5d6b3e0cd52e68e8808debd63d9e71ab1044576f31d479628d23fa71028e875c16db
|
7
|
+
data.tar.gz: 5dc4fb6d4e93470f9d778727cb6d6a045aa42ae02fbc08b99197b69d09356b02af4868d65eede1af56b64a0ac0409032c6443951ce82a1d835bacde5bbbbbd10
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Release History for wordnet
|
2
|
+
|
3
|
+
---
|
4
|
+
|
5
|
+
## v1.2.0 [2023-05-10] Michael Granger <ged@FaerieMUD.org>
|
6
|
+
|
7
|
+
Enhancements:
|
8
|
+
|
9
|
+
- Update for Ruby 3
|
10
|
+
- Improve API docs
|
11
|
+
|
12
|
+
|
13
|
+
## v1.1.0 [2017-09-26] Michael Granger <ged@FaerieMUD.org>
|
14
|
+
|
15
|
+
Enhancements:
|
16
|
+
|
17
|
+
- Update to WordNet 3.1 (from SQLUNet 5.2.0), Sequel 5.0.
|
18
|
+
- Made fetching Synset by ordinal deterministic
|
19
|
+
- Documentation updates/fixes
|
20
|
+
|
21
|
+
|
22
|
+
## v1.0.1 [2016-09-18] Michael Granger <ged@FaerieMUD.org>
|
23
|
+
|
24
|
+
- Finish up and fix WordNet::Sense
|
25
|
+
- Add Wordnet::Synset#wordlist
|
26
|
+
- Documentation fixes, fixes for newer Ruby versions
|
27
|
+
|
28
|
+
|
29
|
+
## v1.0.0 [2012-08-22] Michael Granger <ged@FaerieMUD.org>
|
30
|
+
|
31
|
+
Converted to use Sequel and wnsql.
|
32
|
+
|
33
|
+
|
data/README.md
CHANGED
@@ -1 +1,140 @@
|
|
1
|
-
|
1
|
+
# Ruby-WordNet
|
2
|
+
|
3
|
+
home
|
4
|
+
: https://hg.sr.ht/~ged/ruby-wordnet
|
5
|
+
|
6
|
+
code
|
7
|
+
: https://hg.sr.ht/~ged/ruby-wordnet/browse
|
8
|
+
|
9
|
+
docs
|
10
|
+
: http://deveiate.org/code/wordnet
|
11
|
+
|
12
|
+
github
|
13
|
+
: https://github.com/ged/ruby-wordnet
|
14
|
+
|
15
|
+
|
16
|
+
## Description
|
17
|
+
|
18
|
+
This library is a Ruby interface to WordNet®[https://wordnet.princeton.edu/].
|
19
|
+
WordNet® is an online lexical reference system whose design is inspired by
|
20
|
+
current psycholinguistic theories of human lexical memory. English nouns,
|
21
|
+
verbs, adjectives and adverbs are organized into synonym sets, each
|
22
|
+
representing one underlying lexical concept. Different relations link the
|
23
|
+
synonym sets.
|
24
|
+
|
25
|
+
This library uses SqlUNET[http://sqlunet.sourceforge.net/], which is a
|
26
|
+
conversion of the WordNet (along with a number of other linguistic databases)
|
27
|
+
lexicon flatfiles into a relational database format. You can either install the
|
28
|
+
[wordnet-defaultdb](https://rubygems.org/gems/wordnet-defaultdb) gem, which
|
29
|
+
packages up the SQLite3 version of SqlUNet, or install your own and point the
|
30
|
+
lexicon at it by passing [Sequel connection
|
31
|
+
parameters](http://sequel.jeremyevans.net/rdoc/files/doc/opening_databases_rdoc.html)
|
32
|
+
to the constructor.
|
33
|
+
|
34
|
+
## Usage
|
35
|
+
|
36
|
+
There are three major parts to this library:
|
37
|
+
|
38
|
+
WordNet::Lexicon
|
39
|
+
: the interface to the dictionary, used to connect to the
|
40
|
+
database and look up Words and Synsets.
|
41
|
+
|
42
|
+
WordNet::Word
|
43
|
+
: the English word entries in the Lexicon that are mapped
|
44
|
+
to Synsets via one or more Senses.
|
45
|
+
|
46
|
+
WordNet::Synset
|
47
|
+
: the main artifact of WordNet: a "synonym set". These
|
48
|
+
: are connected to one or more Words through a Sense,
|
49
|
+
and are connected to each other via SemanticLinks.
|
50
|
+
|
51
|
+
The other object classes exist mostly as a way of representing relationships
|
52
|
+
between the main three:
|
53
|
+
|
54
|
+
WordNet::Sense
|
55
|
+
: represents a link between one or more Words and
|
56
|
+
one or more Synsets for one meaning of the word.
|
57
|
+
|
58
|
+
WordNet::SemanticLink
|
59
|
+
: represents a link between Synsets
|
60
|
+
|
61
|
+
WordNet::LexicalLink
|
62
|
+
: represents a link between Words in Synsets
|
63
|
+
|
64
|
+
WordNet::Morph
|
65
|
+
: an interface to a lookup table of irregular word
|
66
|
+
forms mapped to their base form (lemma)
|
67
|
+
|
68
|
+
|
69
|
+
The last class (WordNet::Model) is the abstract superclass for all the others,
|
70
|
+
and inherits most of its functionality from Sequel::Model, the ORM layer
|
71
|
+
of the Sequel toolkit. It's mostly just a container for the database
|
72
|
+
connection, with some convenience methods to allow the database connection
|
73
|
+
to be deferred until runtime instead of when the library loads.
|
74
|
+
|
75
|
+
The library also comes with the beginnings of support for the SUMO-WordNet
|
76
|
+
mapping:
|
77
|
+
|
78
|
+
WordNet::SumoTerm
|
79
|
+
: [Suggested Upper Merged Ontology](http://www.ontologyportal.org/) terms,
|
80
|
+
with associations back to related Synsets.
|
81
|
+
|
82
|
+
As mentioned above, SqlUNet has done an amazing job of linking up a number of
|
83
|
+
other useful linguistic lexicons via WordNet synsets. I plan on adding support
|
84
|
+
for at minimum VerbNet, FrameNet, and PropBank.
|
85
|
+
|
86
|
+
|
87
|
+
## Requirements
|
88
|
+
|
89
|
+
* Ruby >= 3.0
|
90
|
+
* Sequel >= 5.0
|
91
|
+
|
92
|
+
|
93
|
+
## Contributing
|
94
|
+
|
95
|
+
You can check out the current development source with Mercurial via its
|
96
|
+
[project page](https://hg.sr.ht/~ged/ruby-wordnet). Or if you prefer
|
97
|
+
Git, via [its Github mirror](https://github.com/ged/ruby-wordnet).
|
98
|
+
|
99
|
+
After checking out the source, run:
|
100
|
+
|
101
|
+
$ gem install -Ng
|
102
|
+
$ rake setup
|
103
|
+
|
104
|
+
This will do any necessary development environment set up.
|
105
|
+
|
106
|
+
|
107
|
+
## Authors
|
108
|
+
|
109
|
+
* Michael Granger <ged@FaerieMUD.org>
|
110
|
+
|
111
|
+
|
112
|
+
## License
|
113
|
+
|
114
|
+
Copyright (c) 2002-2023, Michael Granger
|
115
|
+
All rights reserved.
|
116
|
+
|
117
|
+
Redistribution and use in source and binary forms, with or without
|
118
|
+
modification, are permitted provided that the following conditions are met:
|
119
|
+
|
120
|
+
* Redistributions of source code must retain the above copyright notice,
|
121
|
+
this list of conditions and the following disclaimer.
|
122
|
+
|
123
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
124
|
+
this list of conditions and the following disclaimer in the documentation
|
125
|
+
and/or other materials provided with the distribution.
|
126
|
+
|
127
|
+
* Neither the name of the author/s, nor the names of the project's
|
128
|
+
contributors may be used to endorse or promote products derived from this
|
129
|
+
software without specific prior written permission.
|
130
|
+
|
131
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
132
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
133
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
134
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
135
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
136
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
137
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
138
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
139
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
140
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/lib/wordnet/constants.rb
CHANGED
data/lib/wordnet/lexicallink.rb
CHANGED
data/lib/wordnet/lexicon.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
-
#encoding: utf-8
|
3
2
|
|
4
3
|
require 'pathname'
|
5
4
|
require 'loggability'
|
@@ -224,11 +223,13 @@ class WordNet::Lexicon
|
|
224
223
|
### #lookup_synsets instead.
|
225
224
|
###
|
226
225
|
### The +word+ can be one of:
|
227
|
-
###
|
226
|
+
###
|
227
|
+
### [+Integer+]
|
228
228
|
### Looks up the corresponding Word or Synset by ID. This assumes that all Synset IDs are
|
229
229
|
### all 9 digits or greater, which is true as of WordNet 3.1. Any additional +args+ are
|
230
230
|
### ignored.
|
231
|
-
###
|
231
|
+
###
|
232
|
+
### [+Symbol+, +String+]
|
232
233
|
### Look up a Word by its gloss using #lookup_synsets, passing any additional +args+,
|
233
234
|
### and return the first one that is found.
|
234
235
|
def []( word, *args )
|
@@ -250,13 +251,13 @@ class WordNet::Lexicon
|
|
250
251
|
###
|
251
252
|
### The *args* can contain:
|
252
253
|
###
|
253
|
-
### [Integer
|
254
|
+
### [+Integer+, +Range+]
|
254
255
|
### The sense/s of the Word (1-indexed) to use when searching for Synsets. If not specified,
|
255
256
|
### all senses of the +word+ are used.
|
256
|
-
### [Regexp]
|
257
|
+
### [+Regexp+]
|
257
258
|
### The Word's Synsets are filtered by definition using an RLIKE filter. Note that not all
|
258
259
|
### databases (including the default one, sqlite3) support RLIKE.
|
259
|
-
### [Symbol
|
260
|
+
### [+Symbol+, +String+]
|
260
261
|
### If it matches one of either a lexical domain (e.g., "verb.motion") or a part of
|
261
262
|
### speech (e.g., "adjective", :noun, :v), the resulting Synsets are filtered by that
|
262
263
|
### criteria.
|
data/lib/wordnet/model.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
-
#encoding: utf-8
|
3
2
|
|
4
3
|
require 'loggability'
|
5
4
|
require 'sequel'
|
@@ -37,7 +36,6 @@ module WordNet
|
|
37
36
|
|
38
37
|
|
39
38
|
### Reset the database connection that all model objects will use.
|
40
|
-
### @param [Sequel::Database] newdb the new database object.
|
41
39
|
def self::db=( newdb )
|
42
40
|
Loggability.with_level( :fatal ) do
|
43
41
|
super
|
data/lib/wordnet/morph.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
-
#encoding: utf-8
|
3
2
|
|
4
3
|
require 'wordnet' unless defined?( WordNet )
|
5
4
|
require 'wordnet/model'
|
@@ -22,6 +21,15 @@ class WordNet::Morph < WordNet::Model( :morphs )
|
|
22
21
|
|
23
22
|
set_primary_key :morphid
|
24
23
|
|
24
|
+
|
25
|
+
##
|
26
|
+
# :method: morphid
|
27
|
+
# The Integer ID of the morph
|
28
|
+
|
29
|
+
##
|
30
|
+
# :method: morph
|
31
|
+
# The text of the morph
|
32
|
+
|
25
33
|
# Table "public.morphmaps"
|
26
34
|
# Column | Type | Modifiers
|
27
35
|
# ---------+--------------+-------------------------------
|
@@ -35,6 +43,9 @@ class WordNet::Morph < WordNet::Model( :morphs )
|
|
35
43
|
# Foreign-key constraints:
|
36
44
|
# "fk_morphmaps_morphid" FOREIGN KEY (morphid) REFERENCES morphs(morphid)
|
37
45
|
# "fk_morphmaps_wordid" FOREIGN KEY (wordid) REFERENCES words(wordid)
|
46
|
+
|
47
|
+
##
|
48
|
+
# The WordNet::Word entries associated with this Morph
|
38
49
|
many_to_many :words,
|
39
50
|
join_table: :morphmaps,
|
40
51
|
right_key: :wordid,
|
data/lib/wordnet/semanticlink.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
-
#encoding: utf-8
|
3
2
|
|
4
3
|
require 'wordnet' unless defined?( WordNet )
|
5
4
|
require 'wordnet/constants'
|
@@ -12,11 +11,19 @@ class WordNet::SemanticLink < WordNet::Model( :semlinks )
|
|
12
11
|
|
13
12
|
set_primary_key [:synset1id, :synset2id, :linkid]
|
14
13
|
|
14
|
+
##
|
15
|
+
# :method: linkid
|
16
|
+
# The ID of this semlink
|
17
|
+
|
18
|
+
##
|
19
|
+
# The "origin" WordNet::Synset associated with this SemanticLink
|
15
20
|
many_to_one :origin,
|
16
21
|
class: 'WordNet::Synset',
|
17
22
|
key: :synset1id,
|
18
23
|
primary_key: :synsetid
|
19
24
|
|
25
|
+
##
|
26
|
+
# The "target" WordNet::Synset associated with this SemanticLink
|
20
27
|
one_to_one :target,
|
21
28
|
class: 'WordNet::Synset',
|
22
29
|
key: :synsetid,
|
data/lib/wordnet/sense.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
-
#encoding: utf-8
|
3
2
|
|
4
3
|
require 'wordnet' unless defined?( WordNet )
|
5
4
|
require 'wordnet/model'
|
@@ -10,6 +9,50 @@ class WordNet::Sense < WordNet::Model( :senses )
|
|
10
9
|
|
11
10
|
set_primary_key :senseid
|
12
11
|
|
12
|
+
# Table "wn.senses"
|
13
|
+
# Column | Type | Collation | Nullable | Default
|
14
|
+
# -------------+------------------------+-----------+----------+-------------
|
15
|
+
# wordid | bigint | | not null | '0'::bigint
|
16
|
+
# casedwordid | bigint | | |
|
17
|
+
# synsetid | bigint | | not null | '0'::bigint
|
18
|
+
# senseid | bigint | | |
|
19
|
+
# sensenum | bigint | | not null | '0'::bigint
|
20
|
+
# lexid | bigint | | not null | '0'::bigint
|
21
|
+
# tagcount | bigint | | |
|
22
|
+
# sensekey | character varying(100) | | |
|
23
|
+
# Indexes:
|
24
|
+
# "idx_192341_primary" PRIMARY KEY, btree (wordid, synsetid)
|
25
|
+
# "k_senses_lexid" btree (lexid)
|
26
|
+
# "k_senses_synsetid" btree (synsetid)
|
27
|
+
# "k_senses_wordid" btree (wordid)
|
28
|
+
# "unq_senses_senseid" UNIQUE, btree (senseid)
|
29
|
+
# "unq_senses_sensekey" UNIQUE, btree (sensekey)
|
30
|
+
# Foreign-key constraints:
|
31
|
+
# "senses_synsetid_fkey" FOREIGN KEY (synsetid) REFERENCES synsets(synsetid)
|
32
|
+
# "senses_wordid_fkey" FOREIGN KEY (wordid) REFERENCES words(wordid)
|
33
|
+
#
|
34
|
+
|
35
|
+
##
|
36
|
+
# :method: wordid
|
37
|
+
# The integer ID of the WordNet::Word this Sense is linked to
|
38
|
+
|
39
|
+
##
|
40
|
+
# :method: synsetid
|
41
|
+
# The integer ID Of the WordNet::Synset this Sense is linked to.
|
42
|
+
|
43
|
+
##
|
44
|
+
# :method: senseid
|
45
|
+
# The unique integer ID of the Sense.
|
46
|
+
|
47
|
+
##
|
48
|
+
# :method: sensenum
|
49
|
+
# The index of this Sense in relation to its Synset
|
50
|
+
|
51
|
+
##
|
52
|
+
# :method: sensekey
|
53
|
+
# The raw sense key as it appeared in the sources
|
54
|
+
|
55
|
+
|
13
56
|
##
|
14
57
|
# The Synset this is a Sense for
|
15
58
|
many_to_one :synset, key: :synsetid
|
data/lib/wordnet/sumoterm.rb
CHANGED
data/lib/wordnet/synset.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
-
#encoding: utf-8
|
3
2
|
|
4
3
|
require 'wordnet' unless defined?( WordNet )
|
5
4
|
require 'wordnet/constants'
|
@@ -353,7 +352,7 @@ class WordNet::Synset < WordNet::Model( :synsets )
|
|
353
352
|
### Return the table of part-of-speech types, keyed by letter identifier.
|
354
353
|
def self::postype_table
|
355
354
|
@postype_table ||= self.db[:postypes].inject({}) do |hash, row|
|
356
|
-
hash[ row[:pos].
|
355
|
+
hash[ row[:pos].to_sym ] = row[:posname]
|
357
356
|
hash
|
358
357
|
end
|
359
358
|
end
|
data/lib/wordnet/word.rb
CHANGED
data/lib/wordnet.rb
CHANGED
data/spec/helpers.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
# -*- ruby -*-
|
2
|
-
#encoding: utf-8
|
3
|
-
# coding: utf-8
|
4
2
|
|
5
3
|
# SimpleCov test coverage reporting; enable this using the :coverage rake task
|
6
|
-
|
4
|
+
if ENV['COVERAGE']
|
5
|
+
require 'simplecov'
|
6
|
+
SimpleCov.start do
|
7
|
+
add_filter 'spec/'
|
8
|
+
enable_coverage :branch
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
7
12
|
|
8
13
|
$LOAD_PATH.unshift( 'wordnet-defaultdb/lib' )
|
9
14
|
|
@@ -29,8 +34,15 @@ RSpec.configure do |config|
|
|
29
34
|
config.example_status_persistence_file_path = "spec/.state"
|
30
35
|
|
31
36
|
if Gem::Specification.find_all_by_name( 'pg' ).any?
|
32
|
-
|
33
|
-
|
37
|
+
begin
|
38
|
+
dburi = 'postgres:/sqlunet50'
|
39
|
+
Sequel.connect( dburi )
|
40
|
+
$dburi = dburi
|
41
|
+
rescue
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
if ! $dburi
|
34
46
|
config.filter_run_excluding( :requires_pg )
|
35
47
|
unless (( $dburi = WordNet::Lexicon.default_db_uri ))
|
36
48
|
config.filter_run_excluding( :requires_database )
|
data.tar.gz.sig
CHANGED
Binary file
|