Class: FrameNet::Frame::Relation

Inherits:
Object
  • Object
show all
Extended by:
Loggability
Defined in:
lib/frame_net/frame/relation.rb

Overview

A relation between two Frames in FrameNet.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Relation

Create a new instance and yield it to the block if one is given.

Yields:

  • (_self)

Yield Parameters:



31
32
33
34
35
36
# File 'lib/frame_net/frame/relation.rb', line 31

def initialize
	@type = nil
	@frame_ids = []

	yield( self ) if block_given?
end

Instance Attribute Details

#frame_idsObject

The IDs of the Frames in this relation with the owning Frame.



49
50
51
# File 'lib/frame_net/frame/relation.rb', line 49

def frame_ids
  @frame_ids
end

#typeObject

The type of the relation (e.g., “Inherits from”, “Is Inherited by”)



45
46
47
# File 'lib/frame_net/frame/relation.rb', line 45

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).



20
21
22
23
24
25
26
27
# File 'lib/frame_net/frame/relation.rb', line 20

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.

Returns:

  • (Boolean)


59
60
61
# File 'lib/frame_net/frame/relation.rb', line 59

def empty?
	return self.frame_ids.empty?
end

#framesObject

Look up and return the related FrameNet::Frames for this Relation.



53
54
55
# File 'lib/frame_net/frame/relation.rb', line 53

def frames
	return self.frame_ids.map {|id| FrameNet::Frame.load_by_id(id) }
end