wordnet 1.0.0.pre.134 → 1.0.0.pre.136

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.tar.gz.sig CHANGED
@@ -1 +1 @@
1
- �<�L}XJ��5��-�TLW%������cʵ?���O��dj��#��}/���KS*�m��H����Y��.G>� zgFr�� m#ʮ���$�:h瀾V�d�rn�\~jD��*޴��$��GRFŜ)��_q��a���vDdsQv��䔰'} $�qe����^���02��L0��s�T���4v4d���� x����,MJ;���!�N ���~�[��j�٧�����;ޠ#�z�.$.N`O�u
1
+ o�ۡʸ�`)�&�T����\�RBo(��FM�nP�,�;m��V�]�cTV7���}�WF�w \��?�Z�/�}]QX�c����V�H��t%�{���n�1l��~�� "繤����%[c�b3-Bݍ�����4lſ�~����ꮡ��t������)�V}���;r�������>(\N�-����wơY
data/README.rdoc CHANGED
@@ -4,18 +4,19 @@
4
4
 
5
5
  == Description
6
6
 
7
- This library is a Ruby interface to WordNet®. WordNet® is an online lexical
8
- reference system whose design is inspired by current psycholinguistic theories
9
- of human lexical memory. English nouns, verbs, adjectives and adverbs are
10
- organized into synonym sets, each representing one underlying lexical
11
- concept. Different relations link the synonym sets.
12
-
13
- It uses WordNet-SQL, which is a conversion of the lexicon flatfiles into a
14
- relational database format. You can either install the 'wordnet-defaultdb' gem,
15
- which packges up the SQLite3 version of WordNet-SQL, or install your own and
16
- point the lexicon at it by passing a Sequel URL to the constructor.
17
-
18
- TO-DO: More details and better writing later.
7
+ This library is a Ruby interface to WordNet®. WordNet® is an online
8
+ lexical reference system whose design is inspired by current
9
+ psycholinguistic theories of human lexical memory. English nouns, verbs,
10
+ adjectives and adverbs are organized into synonym sets, each
11
+ representing one underlying lexical concept. Different relations link
12
+ the synonym sets.
13
+
14
+ It uses WordNet-SQL, which is a conversion of the lexicon flatfiles into
15
+ a relational database format. You can either install the 'wordnet-
16
+ defaultdb' gem, which packages up the SQLite3 version of WordNet-SQL, or
17
+ install your own and point the lexicon at it by passing a Sequel URL to
18
+ the constructor.
19
+
19
20
 
20
21
 
21
22
  == Requirements
@@ -209,5 +209,13 @@ class WordNet::Lexicon
209
209
  return dataset.all
210
210
  end
211
211
 
212
+
213
+ ### Return a human-readable string representation of the Lexicon, suitable for
214
+ ### debugging.
215
+ def inspect
216
+ return "#<%p:%0#x %s>" % [ self.class, self.object_id * 2, self.db.url ]
217
+ end
218
+
219
+
212
220
  end # class WordNet::Lexicon
213
221
 
data/lib/wordnet/model.rb CHANGED
@@ -13,10 +13,6 @@ module WordNet
13
13
  # The base WordNet database-backed domain class. It's a subclass of Sequel::Model, so
14
14
  # you'll first need to be familiar with Sequel (http://sequel.rubyforge.org/) and
15
15
  # especially its Sequel::Model ORM.
16
- #
17
- # See the Sequel::Plugins::InlineMigrations module and the documentation for the
18
- # 'validation_helpers', 'schema', and 'subclasses' Sequel plugins.
19
- #
20
16
  class Model < Sequel::Model
21
17
  extend Loggability
22
18
 
@@ -414,6 +414,32 @@ class WordNet::Synset < WordNet::Model( :synsets )
414
414
  semantic_link :verb_groups
415
415
 
416
416
 
417
+ #
418
+ # :section: Traversal Methods
419
+ #
420
+
421
+ ### Union: Return the least general synset that the receiver and
422
+ ### +othersyn+ have in common as a hypernym, or nil if it doesn't share
423
+ ### any.
424
+ def |( othersyn )
425
+
426
+ # Find all of this syn's hypernyms
427
+ hypersyns = self.traverse( :hypernyms ).to_a
428
+ commonsyn = nil
429
+
430
+ # Now traverse the other synset's hypernyms looking for one of our
431
+ # own hypernyms.
432
+ othersyn.traverse( :hypernyms ) do |syn|
433
+ if hypersyns.include?( syn )
434
+ commonsyn = syn
435
+ throw :stop_traversal
436
+ end
437
+ end
438
+
439
+ return commonsyn
440
+ end
441
+
442
+
417
443
  ### With a block, yield a WordNet::Synset related to the receiver via a link of
418
444
  ### the specified +type+, recursing depth first into each of its links if the link
419
445
  ### type is recursive. To exit from the traversal at any depth, throw :stop_traversal.
@@ -429,16 +455,16 @@ class WordNet::Synset < WordNet::Model( :synsets )
429
455
  traversals = [ self.semanticlink_enum(type) ]
430
456
  syn = nil
431
457
  typekey = SEMANTIC_TYPEKEYS[ type ]
432
- recurses = self.linktypes[ typekey ][:recurses]
458
+ recurses = self.class.linktypes[ typekey ][:recurses]
433
459
 
434
460
  self.log.debug "Traversing %s semlinks%s" % [ type, recurses ? " (recursive)" : '' ]
435
461
 
436
462
  catch( :stop_traversal ) do
437
463
  until traversals.empty?
438
464
  begin
439
- self.log.debug " %d traversal/s left"
465
+ self.log.debug " %d traversal/s left" % [ traversals.length ]
440
466
  syn = traversals.last.next
441
- yielder.yield( syn, traversals.length )
467
+ yielder.yield( syn )
442
468
  traversals << syn.semanticlink_enum( type ) if recurses
443
469
  rescue StopIteration
444
470
  traversals.pop
@@ -460,5 +486,19 @@ class WordNet::Synset < WordNet::Model( :synsets )
460
486
  return depth
461
487
  end
462
488
 
489
+
490
+ ### Return a human-readable representation of the objects, suitable for debugging.
491
+ def inspect
492
+ return "#<%p:%0#x {%d} '%s' (%s): [%s] %s>" % [
493
+ self.class,
494
+ self.object_id * 2,
495
+ self.synsetid,
496
+ self.words.map(&:to_s).join(', '),
497
+ self.part_of_speech,
498
+ self.lexical_domain,
499
+ self.definition,
500
+ ]
501
+ end
502
+
463
503
  end # class WordNet::Synset
464
504
 
@@ -78,8 +78,51 @@ describe WordNet::Synset, :requires_database => true do
78
78
  enum.should be_a( Enumerator )
79
79
  end
80
80
 
81
+ it "can recursively traverse its semantic links" do
82
+ res = @synset.traverse( :hypernyms ).to_a
83
+ res.should have( 6 ).members
84
+ res.should == [
85
+ WordNet::Synset[ 104341686 ],
86
+ WordNet::Synset[ 100021939 ],
87
+ WordNet::Synset[ 100003553 ],
88
+ WordNet::Synset[ 100002684 ],
89
+ WordNet::Synset[ 100001930 ],
90
+ WordNet::Synset[ 100001740 ],
91
+ ]
92
+ end
93
+
94
+ it "can return an Enumerator for recursively traversing its semantic links" do
95
+ enum = @synset.traverse( :hypernyms )
96
+
97
+ enum.next.should == WordNet::Synset[ 104341686 ]
98
+ enum.next.should == WordNet::Synset[ 100021939 ]
99
+ enum.next.should == WordNet::Synset[ 100003553 ]
100
+ enum.next.should == WordNet::Synset[ 100002684 ]
101
+ enum.next.should == WordNet::Synset[ 100001930 ]
102
+ enum.next.should == WordNet::Synset[ 100001740 ]
103
+ expect {
104
+ enum.next
105
+ }.to raise_error( StopIteration )
106
+ end
107
+
108
+
109
+ end
110
+
111
+ context "for 'knight (noun)' [110238375]" do
112
+
113
+ before( :each ) do
114
+ @synset = @lexicon[ :knight, "noble" ]
115
+ end
116
+
117
+ it "can find the hypernym that it and another synset share in common through the intersection operator" do
118
+ res = @synset | @lexicon[ :squire ]
119
+ res.should == @lexicon[:person]
120
+ end
121
+
81
122
  end
82
123
 
124
+
125
+
83
126
  end
84
127
 
85
128
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wordnet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.134
4
+ version: 1.0.0.pre.136
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -36,7 +36,7 @@ cert_chain:
36
36
  YUhDS0xaZFNLai9SSHVUT3QrZ2JsUmV4OEZBaDhOZUEKY21saFhlNDZwWk5K
37
37
  Z1dLYnhaYWg4NWpJang5NWhSOHZPSStOQU01aUg5a09xSzEzRHJ4YWNUS1Bo
38
38
  cWo1UGp3RgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
39
- date: 2012-08-06 00:00:00.000000000 Z
39
+ date: 2012-08-15 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sequel
@@ -167,27 +167,27 @@ dependencies:
167
167
  - !ruby/object:Gem::Version
168
168
  version: '3.0'
169
169
  description: ! 'This library is a Ruby interface to WordNet®. WordNet® is an online
170
- lexical
171
170
 
172
- reference system whose design is inspired by current psycholinguistic theories
171
+ lexical reference system whose design is inspired by current
173
172
 
174
- of human lexical memory. English nouns, verbs, adjectives and adverbs are
173
+ psycholinguistic theories of human lexical memory. English nouns, verbs,
175
174
 
176
- organized into synonym sets, each representing one underlying lexical
175
+ adjectives and adverbs are organized into synonym sets, each
177
176
 
178
- concept. Different relations link the synonym sets.
177
+ representing one underlying lexical concept. Different relations link
179
178
 
179
+ the synonym sets.
180
180
 
181
- It uses WordNet-SQL, which is a conversion of the lexicon flatfiles into a
182
181
 
183
- relational database format. You can either install the ''wordnet-defaultdb'' gem,
182
+ It uses WordNet-SQL, which is a conversion of the lexicon flatfiles into
184
183
 
185
- which packges up the SQLite3 version of WordNet-SQL, or install your own and
184
+ a relational database format. You can either install the ''wordnet-
186
185
 
187
- point the lexicon at it by passing a Sequel URL to the constructor.
186
+ defaultdb'' gem, which packages up the SQLite3 version of WordNet-SQL, or
188
187
 
188
+ install your own and point the lexicon at it by passing a Sequel URL to
189
189
 
190
- TO-DO: More details and better writing later.'
190
+ the constructor.'
191
191
  email:
192
192
  - ged@FaerieMUD.org
193
193
  executables: []
metadata.gz.sig CHANGED
Binary file