Class: FrameNet::Frame::Relation
- Inherits:
-
Object
- Object
- FrameNet::Frame::Relation
- Extended by:
- Loggability
- Defined in:
- lib/frame_net/frame/relation.rb
Overview
A relation between two Frames in FrameNet.
Instance Attribute Summary collapse
-
#frame_ids ⇒ Object
The IDs of the Frames in this relation with the owning Frame.
-
#type ⇒ Object
The type of the relation (e.g., “Inherits from”, “Is Inherited by”).
Class Method Summary collapse
-
.from_frame_data(doc) ⇒ Object
Load one or more instances from the specified
doc(a LibXML::XML::Document parsed from a FrameNet frame).
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Returns
trueif there are no frames with this relation. -
#frames ⇒ Object
Look up and return the related FrameNet::Frames for this Relation.
-
#initialize {|_self| ... } ⇒ Relation
constructor
Create a new instance and yield it to the block if one is given.
Constructor Details
#initialize {|_self| ... } ⇒ Relation
Create a new instance and yield it to the block if one is given.
32 33 34 35 36 37 |
# File 'lib/frame_net/frame/relation.rb', line 32 def initialize @type = nil @frame_ids = [] yield( self ) if block_given? end |
Instance Attribute Details
#frame_ids ⇒ Object
The IDs of the Frames in this relation with the owning Frame.
50 51 52 |
# File 'lib/frame_net/frame/relation.rb', line 50 def frame_ids @frame_ids end |
#type ⇒ Object
The type of the relation (e.g., “Inherits from”, “Is Inherited by”)
46 47 48 |
# File 'lib/frame_net/frame/relation.rb', line 46 def type @type end |
Class Method Details
.from_frame_data(doc) ⇒ Object
Load one or more instances from the specified doc (a LibXML::XML::Document parsed from a FrameNet frame).
21 22 23 24 25 26 27 28 |
# File 'lib/frame_net/frame/relation.rb', line 21 def self::from_frame_data( doc ) return doc.find( '//fn:frameRelation' ).map do |node| new do |relation| relation.type = node['type'] relation.frame_ids = node.find( './fn:relatedFrame' ).map {|node| node['ID']} end end end |
Instance Method Details
#empty? ⇒ Boolean
Returns true if there are no frames with this relation.
60 61 62 |
# File 'lib/frame_net/frame/relation.rb', line 60 def empty? return self.frame_ids.empty? end |
#frames ⇒ Object
Look up and return the related FrameNet::Frames for this Relation.
54 55 56 |
# File 'lib/frame_net/frame/relation.rb', line 54 def frames return self.frame_ids.map {|id| FrameNet::Frame.load_by_id(id) } end |