ruby-framenet 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c88c1ca1204059a078b33a7b0426869d0a868965
4
- data.tar.gz: f72db66b5f6d19ddc308f2a79ac557b4c11853a4
3
+ metadata.gz: 47b197dcde86a3220d55e93261bb5d685e7f39dd
4
+ data.tar.gz: 30fb45106a85f3d553e21470df98331d4023a252
5
5
  SHA512:
6
- metadata.gz: 742517a87853ff4bfb88d0669b67670f77ee04b3b4bbda2ed40f2b1d9ff042390f9fbb4f5c8f999abe42c5bd9c330ace1e2950aeecbcea4585979850a2a5395b
7
- data.tar.gz: d4767491967d59cad4148af31f90f7828242f77524ddb452ab7f7fb4535c3d3a2840d4aea7ebb00aad2f0e1f85828f90af9b8c615b34876068a1741d9ef50d5e
6
+ metadata.gz: d92518f10cc59a6bdc93685a3214d8a5c169f4f507b43f195f81628943c386389fa07959d39b35fa093e09bc55bd560860fa7e003a77b19cd75fb849253d93bb
7
+ data.tar.gz: 17f117eca8bcda0f1bb3a847a9130f2c9cea425f466563691b054b821dceedc752666eac6ebccd2f0853149468e560916b21c3d261db6dd1c1b6417066dd42b1
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,8 +1,43 @@
1
+ 2017-03-09 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ * .hgtags:
4
+ Added tag v0.0.2 for changeset 88e23983e25b
5
+ [d009ab23eff8] [tip]
6
+
7
+ * .hgsigs:
8
+ Added signature for changeset a275939b201e
9
+ [88e23983e25b] [v0.0.2]
10
+
11
+ * Rakefile, ruby-framenet.gemspec:
12
+ Fix gemspec Rake dependency, update gemspec.
13
+ [a275939b201e]
14
+
15
+ * History.md, lib/frame_net.rb:
16
+ Bump the patch version, update history.
17
+ [ecb01eee279b]
18
+
19
+ * Manifest.txt, lib/frame_net/frame.rb,
20
+ spec/frame_net/frame/relation_spec.rb, spec/frame_net/frame_spec.rb:
21
+ Add Frame convenience methods
22
+
23
+ - Add Frame#==
24
+ - Add Frame#elements_by_id and #elements_by_core_type
25
+ - Add convenience methods for looking up related frames
26
+ [a185289295b0] [github/master]
27
+
28
+ * README.md, Rakefile, ruby-framenet.gemspec:
29
+ Fix documentation build and a few README issues.
30
+ [4bcb2a9ed913]
31
+
1
32
  2017-03-08 Michael Granger <ged@FaerieMUD.org>
2
33
 
34
+ * .hgignore, Rakefile:
35
+ Allow publication in the Rakefile, ignore the doc/ directory
36
+ [47438d76ee9d]
37
+
3
38
  * .hgtags:
4
39
  Added tag v0.0.1 for changeset 4445b83a4072
5
- [4d9c19148c6f] [github/master, tip]
40
+ [4d9c19148c6f]
6
41
 
7
42
  * .hgsigs:
8
43
  Added signature for changeset 546079d302b4
data/History.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## v0.0.2 [2017-03-09] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Enhancements:
4
+
5
+ - Add Frame#==
6
+ - Add Frame#elements_by_id and #elements_by_core_type
7
+ - Add convenience methods for looking up related frames
8
+
9
+
1
10
  ## v0.0.1 [2017-03-08] Michael Granger <ged@FaerieMUD.org>
2
11
 
3
12
  Initial release.
data/Manifest.txt CHANGED
@@ -14831,6 +14831,7 @@ lib/libxml/monkeypatches.rb
14831
14831
  spec/frame_net/definition_spec.rb
14832
14832
  spec/frame_net/frame/element_spec.rb
14833
14833
  spec/frame_net/frame/lexical_unit_spec.rb
14834
+ spec/frame_net/frame/relation_spec.rb
14834
14835
  spec/frame_net/frame_spec.rb
14835
14836
  spec/frame_net/semantic_type_spec.rb
14836
14837
  spec/frame_net_spec.rb
data/README.md CHANGED
@@ -15,7 +15,8 @@ docs
15
15
 
16
16
  ## Description
17
17
 
18
- This is a Ruby interface to FrameNet, a lexical database of English word usage.
18
+ This is a Ruby interface to FrameNet, a lexical database of English word usage. It
19
+ includes version 1.7 of the FrameNet data, and Ruby classes for querying them.
19
20
 
20
21
  ### Usage
21
22
 
@@ -46,8 +47,8 @@ You can look up frames either by name or by numeric ID:
46
47
  ## Contributing
47
48
 
48
49
  You can check out the current development source with Mercurial via its
49
- {project page}[http://bitbucket.org/ged/framenet]. Or if you prefer Git, via
50
- {its Github mirror}[https://github.com/ged/framenet].
50
+ [project page](http://bitbucket.org/ged/framenet). Or if you prefer Git, via
51
+ [its Github mirror](https://github.com/ged/framenet).
51
52
 
52
53
  After checking out the source, run:
53
54
 
@@ -61,12 +62,12 @@ and generate the API documentation.
61
62
 
62
63
  This library includes data from the FrameNet project:
63
64
 
64
- https://framenet.icsi.berkeley.edu/
65
+ > https://framenet.icsi.berkeley.edu/
65
66
 
66
- It is distributed under the terms of the Creative Commons Attribution
67
+ which is distributed under the terms of the Creative Commons Attribution
67
68
  license:
68
69
 
69
- https://creativecommons.org/licenses/by/4.0/
70
+ > https://creativecommons.org/licenses/by/4.0/
70
71
 
71
72
  Everything else:
72
73
 
data/Rakefile CHANGED
@@ -14,13 +14,12 @@ Hoe.plugin :signing
14
14
  Hoe.plugin :deveiate
15
15
 
16
16
  Hoe.plugins.delete :rubyforge
17
- Hoe.plugins.delete :gemcutter # Remove for public gems
18
17
 
19
18
  hoespec = Hoe.spec 'ruby-framenet' do |spec|
20
- self.readme_file = 'README.md'
21
- self.history_file = 'History.md'
22
- self.extra_rdoc_files = FileList[ '*.md' ]
23
- self.urls = {
19
+ spec.readme_file = 'README.md'
20
+ spec.history_file = 'History.md'
21
+ spec.extra_rdoc_files = FileList[ '*.md' ]
22
+ spec.urls = {
24
23
  home: 'http://deveiate.org/projects/ruby-framenet',
25
24
  code: 'http://bitbucket.org/ged/ruby-framenet',
26
25
  docs: 'http://deveiate.org/code/ruby-framenet',
@@ -42,7 +41,7 @@ hoespec = Hoe.spec 'ruby-framenet' do |spec|
42
41
  spec.hg_sign_tags = true if spec.respond_to?( :hg_sign_tags= )
43
42
  spec.check_history_on_release = true if spec.respond_to?( :check_history_on_release= )
44
43
 
45
- self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
44
+ spec.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
46
45
  end
47
46
 
48
47
 
@@ -71,9 +70,9 @@ if File.directory?( '.hg' )
71
70
 
72
71
  Rake::Task[ 'docs' ].clear
73
72
  RDoc::Task.new( 'docs' ) do |rdoc|
74
- rdoc.main = "README.rdoc"
73
+ rdoc.main = "README.md"
75
74
  rdoc.markup = 'markdown'
76
- rdoc.rdoc_files.include( "*.rdoc", "ChangeLog", "lib/**/*.rb" )
75
+ rdoc.rdoc_files.include( "*.md", "ChangeLog", "lib/**/*.rb" )
77
76
  rdoc.generator = :fivefish
78
77
  rdoc.title = 'FrameNet'
79
78
  rdoc.rdoc_dir = 'doc'
@@ -81,7 +80,7 @@ if File.directory?( '.hg' )
81
80
  end
82
81
 
83
82
  task :gemspec => GEMSPEC
84
- file GEMSPEC => __FILE__
83
+ file GEMSPEC => [ __FILE__, 'lib/frame_net.rb' ]
85
84
  task GEMSPEC do |task|
86
85
  spec = $hoespec.spec
87
86
  spec.files.delete( '.gemtest' )
data/lib/frame_net.rb CHANGED
@@ -16,10 +16,10 @@ module FrameNet
16
16
  extend Loggability
17
17
 
18
18
  # Package version
19
- VERSION = '0.0.1'
19
+ VERSION = '0.0.2'
20
20
 
21
21
  # Version control revision
22
- REVISION = %q$Revision: 767b08e54e6a $
22
+ REVISION = %q$Revision: ecb01eee279b $
23
23
 
24
24
  # The Pathname for the library's data directory, taken from the
25
25
  # FRAME_NET_DATA_DIR env variable first, then the datadir for the ruby-framenet
@@ -34,6 +34,7 @@ class FrameNet::Frame
34
34
  raise ArgumentError, "don't know how to load a frame from a %p" % [ name_or_id.class ]
35
35
  end
36
36
  end
37
+ class << self; alias_method :[], :load; end
37
38
 
38
39
 
39
40
  ### Return a LibXML::XML::Document for the data for the frame named +name+.
@@ -120,6 +121,14 @@ class FrameNet::Frame
120
121
  attr_accessor :lexical_units
121
122
 
122
123
 
124
+ ### Object equality -- returns +true+ if the receiver repressents the same
125
+ ### FrameNet frame as +other_frame+.
126
+ def ==( other_frame )
127
+ return other_frame.is_a?( self.class ) && self.id == other_frame.id
128
+ end
129
+ alias_method :eql?, :==
130
+
131
+
123
132
  ### Return the Frame as a human-readable string suitable for debugging.
124
133
  def inspect
125
134
  return %{#<%p:%#016x "%s" [%d] %d elements, %d relations, %d lexical units>} % [
@@ -134,6 +143,28 @@ class FrameNet::Frame
134
143
  end
135
144
 
136
145
 
146
+ #
147
+ # Elements
148
+ #
149
+
150
+ ### Return the Hash of this Frame's FEs keyed by numeric ID.
151
+ def elements_by_id
152
+ return self.elements.each_with_object( {} ) do |el, hash|
153
+ hash[ el.id ] = el
154
+ end
155
+ end
156
+
157
+
158
+ ### Return a Hash of this Frame's FEs grouped by core type.
159
+ def elements_by_core_type
160
+ return self.elements.group_by( &:core_type )
161
+ end
162
+
163
+
164
+ #
165
+ # Relations
166
+ #
167
+
137
168
  ### Return the FrameNet::Frame::Relations this Frame has as a Hash keyed by the
138
169
  ### Relation's type as a String.
139
170
  def relations_hash
@@ -149,10 +180,93 @@ class FrameNet::Frame
149
180
  end
150
181
 
151
182
 
183
+ ### Return Frames the receiver is inherited by.
184
+ def is_inherited_by
185
+ return self.relations_hash[ "Is Inherited by" ].frames
186
+ end
187
+
188
+
189
+ ### Return Frames in which the receiver is one of several perspectives.
190
+ def perspective_on
191
+ return self.relations_hash[ "Perspective on" ].frames
192
+ end
193
+
194
+
195
+ ### Return Frames which represent different states of affairs of the receiving
196
+ ### Frame.
197
+ def is_perspectivized_in
198
+ return self.relations_hash[ "Is Perspectivized in" ].frames
199
+ end
200
+
201
+
202
+ ### Return Frames the receiver uses in some capacity.
203
+ def uses
204
+ return self.relations_hash[ "Uses" ].frames
205
+ end
206
+
207
+
208
+ ### Return Frames the receiver is used by.
209
+ def is_used_by
210
+ return self.relations_hash[ "Is Used by" ].frames
211
+ end
212
+
213
+
214
+ ### Return Frames the receiver is a subframe of.
215
+ def subframe_of
216
+ return self.relations_hash[ "Subframe of" ].frames
217
+ end
218
+
219
+
220
+ ### Return Frames which are a subframe of the receiver.
221
+ def has_subframes
222
+ return self.relations_hash[ "Has Subframe(s)" ].frames
223
+ end
224
+ alias_method :has_subframe, :has_subframes
225
+
226
+
227
+ ### Return Frames the receiver comes before in a series of subframes of another
228
+ ### Frame.
229
+ def precedes
230
+ return self.relations_hash[ "Precedes" ].frames
231
+ end
232
+
233
+
234
+ ### Return Frames the receiver comes after in a series of subframes of another
235
+ ### Frame.
236
+ def is_preceded_by
237
+ return self.relations_hash[ "Is Preceded by" ].frames
238
+ end
239
+
240
+
241
+ ### Return Frames in which the receiving frame is an inchoative subframe.
242
+ def is_inchoative_of
243
+ return self.relations_hash[ "Is Inchoative of" ].frames
244
+ end
245
+
246
+
247
+ ### Return Frames in which the receiving frame is a causative subframe.
248
+ def is_causative_of
249
+ return self.relations_hash[ "Is Causative of" ].frames
250
+ end
251
+
252
+
253
+ ### Return the other members of a group of Frames which should be compared to
254
+ ### the receiving Frame.
255
+ def see_also
256
+ return self.relations_hash[ "See also" ].frames
257
+ end
258
+
259
+
260
+
261
+ #
262
+ # Utilities/Testing
263
+ #
264
+
152
265
  ### Return the XML document that contains the data for the frame (if one exists). Returns
153
266
  ### +nil+ if the document doesn't exist.
154
267
  def document
155
268
  return self.class.document_for( self.name )
156
269
  end
157
270
 
271
+
158
272
  end # class FrameNet::Frame
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env rspec -cfd
2
+
3
+ require_relative '../../spec_helper'
4
+
5
+ require 'frame_net/frame/relation'
6
+
7
+
8
+ describe FrameNet::Frame::Relation do
9
+
10
+ let( :frame_name ) { :Transition_to_a_situation }
11
+ let( :frame_doc ) { FrameNet.load_document("frame/#{frame_name}.xml") }
12
+
13
+
14
+ it "can be created from a frame XML document" do
15
+ results = described_class.from_frame_data( frame_doc )
16
+
17
+ expect( results ).to be_an( Array ).and( all be_a(described_class) )
18
+ expect( results.length ).to eq( frame_doc.find('/fn:frame/fn:frameRelation').length )
19
+ end
20
+
21
+
22
+ it "can look up its frames" do
23
+ relations = described_class.from_frame_data( frame_doc )
24
+ inherits_from = relations.find {|rel| rel.type == 'Inherits from' }
25
+ expect( inherits_from.frames ).to eq([ FrameNet[:Transition_to_state] ])
26
+ end
27
+
28
+ end
29
+
@@ -39,5 +39,188 @@ describe FrameNet::Frame do
39
39
  expect( result.id ).to eq( 218 )
40
40
  end
41
41
 
42
+
43
+ describe "elements (FEs)" do
44
+
45
+ let( :frame ) { described_class.load(:Becoming_aware) }
46
+
47
+
48
+ it "can return its frame elements keyed by ID" do
49
+ result = frame.elements_by_id
50
+
51
+ expect( result ).to be_a( Hash )
52
+ expect( result.keys ).to all( be_a Integer )
53
+ expect( result.values ).to all( be_a FrameNet::Frame::Element )
54
+ end
55
+
56
+
57
+ it "can return its frame elements grouped by their core type" do
58
+ result = frame.elements_by_core_type
59
+
60
+ expect( result ).to be_a( Hash )
61
+ expect( result.keys ).to all( be_a String )
62
+ expect( result.values ).to all( be_a(Array) )
63
+ end
64
+
65
+ end
66
+
67
+
68
+ describe "relations" do
69
+
70
+ it "can return its relations as a Hash keyed by type" do
71
+ frame = described_class.load( :Statement )
72
+ result = frame.relations_hash
73
+
74
+ expect( result ).to be_a( Hash )
75
+ expect( result.keys ).to all( be_a String )
76
+ expect( result.values ).to all( be_a FrameNet::Frame::Relation )
77
+ end
78
+
79
+
80
+ it "provides a convenience method for fetching 'Inherits from' frames" do
81
+ frame = described_class.load( :Cause_to_experience )
82
+ results = frame.inherits_from
83
+
84
+ expect( results ).to eq([ described_class.load(:Intentionally_affect) ])
85
+ end
86
+
87
+
88
+ it "provides a convenience method for fetching 'Is inherited by' frames" do
89
+ frame = described_class.load( :Intentionally_affect )
90
+ results = frame.is_inherited_by
91
+
92
+ expect( results ).to be_an( Array )
93
+ expect( results.length ).to eq( 47 )
94
+ expect( results ).to include(
95
+ described_class.load( :Attack ),
96
+ described_class.load( :Cause_to_perceive ),
97
+ described_class.load( :Detaching ),
98
+ described_class.load( :Rescuing )
99
+ )
100
+ end
101
+
102
+
103
+ it "provides a convenience method for fetching 'Perspective on' frames" do
104
+ frame = described_class.load( :Growing_food )
105
+ results = frame.perspective_on
106
+
107
+ expect( results ).to be_an( Array )
108
+ expect( results.length ).to eq( 1 )
109
+ expect( results ).to include( described_class.load(:Agriculture) )
110
+ end
111
+
112
+
113
+ it "provides a convenience method for fetching 'Is Perspectivized in' frames" do
114
+ frame = described_class.load( :Simultaneity )
115
+ results = frame.is_perspectivized_in
116
+
117
+ expect( results ).to be_an( Array )
118
+ expect( results.length ).to eq( 2 )
119
+ expect( results ).to include(
120
+ described_class.load(:Temporal_collocation),
121
+ described_class.load(:Location_in_time)
122
+ )
123
+ end
124
+
125
+
126
+ it "provides a convenience method for fetching 'Uses' frames" do
127
+ frame = described_class.load( :Legal_rulings )
128
+ results = frame.uses
129
+
130
+ expect( results ).to be_an( Array )
131
+ expect( results.length ).to eq( 1 )
132
+ expect( results ).to include( described_class.load(:Communication) )
133
+ end
134
+
135
+
136
+ it "provides a convenience method for fetching 'Is Used by' frames" do
137
+ frame = described_class.load( :Intentionally_affect )
138
+ results = frame.is_used_by
139
+
140
+ expect( results ).to be_an( Array )
141
+ expect( results.length ).to eq( 3 )
142
+ expect( results ).to include(
143
+ described_class.load(:Arson),
144
+ described_class.load(:Import_export_scenario),
145
+ described_class.load(:Bungling)
146
+ )
147
+ end
148
+
149
+
150
+ it "provides a convenience method for fetching 'Subframe of' frames" do
151
+ frame = described_class.load( :Planting )
152
+ results = frame.subframe_of
153
+
154
+ expect( results ).to be_an( Array )
155
+ expect( results.length ).to eq( 1 )
156
+ expect( results ).to include( described_class.load(:Agriculture) )
157
+ end
158
+
159
+
160
+ it "provides a convenience method for fetching 'Has Subframe(s)' frames" do
161
+ frame = described_class.load( :Travel )
162
+ results = frame.has_subframe
163
+
164
+ expect( results ).to be_an( Array )
165
+ expect( results.length ).to eq( 1 )
166
+ expect( results ).to include( described_class.load(:Setting_out) )
167
+ end
168
+
169
+
170
+
171
+ it "provides a convenience method for fetching 'Precedes' frames" do
172
+ frame = described_class.load( :Aiming )
173
+ results = frame.precedes
174
+
175
+ expect( results ).to be_an( Array )
176
+ expect( results.length ).to eq( 1 )
177
+ expect( results ).to include( described_class.load(:Hit_or_miss) )
178
+ end
179
+
180
+
181
+
182
+ it "provides a convenience method for fetching 'Is Preceded by' frames" do
183
+ frame = described_class.load( :Sleep )
184
+ results = frame.is_preceded_by
185
+
186
+ expect( results ).to be_an( Array )
187
+ expect( results.length ).to eq( 1 )
188
+ expect( results ).to include( described_class.load(:Fall_asleep) )
189
+ end
190
+
191
+
192
+ it "provides a convenience method for fetching 'Is Inchoative of' frames" do
193
+ frame = described_class.load( :Forming_relationships )
194
+ results = frame.is_inchoative_of
195
+
196
+ expect( results ).to be_an( Array )
197
+ expect( results.length ).to eq( 1 )
198
+ expect( results ).to include( described_class.load(:Personal_relationship) )
199
+ end
200
+
201
+
202
+ it "provides a convenience method for fetching 'Is Causative of' frames" do
203
+ frame = described_class.load( :Cause_change_of_consistency )
204
+ results = frame.is_causative_of
205
+
206
+ expect( results ).to be_an( Array )
207
+ expect( results.length ).to eq( 1 )
208
+ expect( results ).to include( described_class.load(:Change_of_consistency) )
209
+ end
210
+
211
+
212
+
213
+ it "provides a convenience method for fetching 'See also' frames" do
214
+ frame = described_class.load( :Cure )
215
+ results = frame.see_also
216
+
217
+ expect( results ).to be_an( Array )
218
+ expect( results.length ).to eq( 1 )
219
+ expect( results ).to include( described_class.load(:Medical_intervention) )
220
+ end
221
+
222
+
223
+ end
224
+
42
225
  end
43
226
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-framenet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -35,7 +35,7 @@ cert_chain:
35
35
  w8aNA5re5+Rt/Vvjxj5AcEnZnZiz5x959NaddQocX32Z1unHw44pzRNUur1GInfW
36
36
  p4vpx2kUSFSAGjtCbDGTNV2AH8w9OU4xEmNz8c5lyoA=
37
37
  -----END CERTIFICATE-----
38
- date: 2017-03-09 00:00:00.000000000 Z
38
+ date: 2017-03-10 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: loggability
@@ -163,8 +163,9 @@ dependencies:
163
163
  - - "~>"
164
164
  - !ruby/object:Gem::Version
165
165
  version: '3.15'
166
- description: This is a Ruby interface to FrameNet, a lexical database of English word
167
- usage.
166
+ description: |-
167
+ This is a Ruby interface to FrameNet, a lexical database of English word usage. It
168
+ includes version 1.7 of the FrameNet data, and Ruby classes for querying them.
168
169
  email:
169
170
  - ged@FaerieMUD.org
170
171
  executables: []
@@ -15008,6 +15009,7 @@ files:
15008
15009
  - spec/frame_net/definition_spec.rb
15009
15010
  - spec/frame_net/frame/element_spec.rb
15010
15011
  - spec/frame_net/frame/lexical_unit_spec.rb
15012
+ - spec/frame_net/frame/relation_spec.rb
15011
15013
  - spec/frame_net/frame_spec.rb
15012
15014
  - spec/frame_net/semantic_type_spec.rb
15013
15015
  - spec/frame_net_spec.rb
@@ -15038,5 +15040,5 @@ rubygems_version: 2.6.8
15038
15040
  signing_key:
15039
15041
  specification_version: 4
15040
15042
  summary: This is a Ruby interface to FrameNet, a lexical database of English word
15041
- usage.
15043
+ usage
15042
15044
  test_files: []
metadata.gz.sig CHANGED
Binary file