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:



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_idsObject

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

#typeObject

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.

Returns:

  • (Boolean)


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

def empty?
	return self.frame_ids.empty?
end

#framesObject

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