class FrameNet::Frame

A Frame in FrameNet.

References:

Attributes

cDate[RW]

The timestamp of when the node was created

cDate=[RW]

The timestamp of when the node was created

core_element_set_ids[RW]

The sets of FE IDs that make up the Frame' FEcoreSets.

creation_time[RW]

The timestamp of when the node was created

definition[RW]

The definition of the Frame.

elements[RW]

The frame elements associated with the Frame, as an Array of FrameNet::Frame::Elements.

id[RW]

The Frame's ID

lexical_units[RW]

The “lexical units” associated with the frame, as an Array of FrameNet::LexUnits.

name[RW]

The Frame's name as a Symbol

relations[RW]

The frame relations associated with the Frame, as an Array of FrameNet::Frame::Relations.

Public Class Methods

[]( name_or_id )
Alias for: load
document_for( name ) click to toggle source

Return a LibXML::XML::Document for the data for the frame named name.

# File lib/frame_net/frame.rb, line 40
def self::document_for( name )
        path = "frame/%s.xml" % [ name.to_s.capitalize ]
        return FrameNet.load_document( path )
end
load( name_or_id ) click to toggle source

Load the frame by name_or_id.

# File lib/frame_net/frame.rb, line 26
def self::load( name_or_id )
        case name_or_id
        when Numeric
                return FrameNet::Frame.load_by_id( name_or_id )
        when Symbol, String
                return FrameNet::Frame.load_by_name( name_or_id )
        else
                raise ArgumentError, "don't know how to load a frame from a %p" % [ name_or_id.class ]
        end
end
Also aliased as: []
load_by_id( id ) click to toggle source

Look up a Frame by its Integer id.

# File lib/frame_net/frame.rb, line 70
def self::load_by_id( id )
        self.log.debug "Loading frame for ID=%p" % [ id ]
        xpath = %{//fn:frame[@ID=%d]} % [ id ]
        node = FrameNet.frame_index.find_first( xpath ) or return nil
        return self.load_by_name( node['name'] )
end
load_by_name( name ) click to toggle source

Load a Frame from the frame XML for the given name.

# File lib/frame_net/frame.rb, line 47
def self::load_by_name( name )
        self.log.debug "Loading frame named %p" % [ name ]

        doc = self.document_for( name ) or
                raise ArgumentError, "No such frame %p!" % [ name ]

        return new do |frame|
                frame.id = Integer( doc.root['ID'] )
                frame.name = doc.root['name'].to_sym
                frame.creation_time = FrameNet.parse_time( doc.root['cDate'] )
                frame.definition = FrameNet::Definition.from_frame_data( doc )
                frame.elements = FrameNet::Frame::Element.from_frame_data( doc )
                frame.relations = FrameNet::Frame::Relation.from_frame_data( doc )
                frame.lexical_units = FrameNet::Frame::LexicalUnit.from_frame_data( doc )

                frame.core_element_set_ids = doc.find( '//fn:frame/fn:FEcoreSet' ).map do |set_el|
                        set_el.find( './fn:memberFE' ).map {|el| el['ID'].to_i }
                end
        end
end
new() { |self| ... } click to toggle source

Create a new Frame with the specified id, name, and modification_date.

# File lib/frame_net/frame.rb, line 79
def initialize
        @id                   = nil
        @name                 = nil
        @creation_time        = Time.now
        @definition           = nil
        @elements             = []
        @relations            = []
        @lexical_units        = []
        @core_element_set_ids = []

        yield( self ) if block_given?
end

Public Instance Methods

==( other_frame ) click to toggle source

Object equality – returns true if the receiver repressents the same FrameNet frame as other_frame.

# File lib/frame_net/frame.rb, line 134
def ==( other_frame )
        return other_frame.is_a?( self.class ) && self.id == other_frame.id
end
Also aliased as: eql?
core_element_sets() click to toggle source

Return the Frame's core element sets (FEcoreSets) as an Array of FrameNet::Frame::Elements.

# File lib/frame_net/frame.rb, line 174
def core_element_sets
        elements = self.elements_by_id
        return self.core_element_set_ids.map do |id_set|
                id_set.map {|id| elements[id] }
        end
end
document() click to toggle source

Return the XML document that contains the data for the frame (if one exists). Returns nil if the document doesn't exist.

# File lib/frame_net/frame.rb, line 285
def document
        return self.class.document_for( self.name )
end
elements_by_core_type() click to toggle source

Return a Hash of this Frame's FEs grouped by core type.

# File lib/frame_net/frame.rb, line 167
def elements_by_core_type
        return self.elements.group_by( &:core_type )
end
elements_by_id() click to toggle source

Return the Hash of this Frame's FEs keyed by numeric ID.

# File lib/frame_net/frame.rb, line 159
def elements_by_id
        return self.elements.each_with_object( {} ) do |el, hash|
                hash[ el.id ] = el
        end
end
eql?( other_frame )
Alias for: ==
has_subframe()
Alias for: has_subframes
has_subframes() click to toggle source

Return Frames which are a subframe of the receiver.

# File lib/frame_net/frame.rb, line 239
def has_subframes
        return self.relations_hash[ "Has Subframe(s)" ].frames
end
Also aliased as: has_subframe
inherits_from() click to toggle source

Return Frames the receiver inherits from.

# File lib/frame_net/frame.rb, line 196
def inherits_from
        return self.relations_hash[ "Inherits from" ].frames
end
inspect() click to toggle source

Return the Frame as a human-readable string suitable for debugging.

# File lib/frame_net/frame.rb, line 141
def inspect
        return %{#<%p:%#016x "%s" [%d] %d elements, %d relations, %d lexical units>} % [
                self.class,
                self.object_id * 2,
                self.name || "(Unnamed)",
                self.id || 0,
                self.elements.length,
                self.relations.count {|rel| !rel.empty? },
                self.lexical_units.length,
        ]
end
is_causative_of() click to toggle source

Return Frames in which the receiving frame is a causative subframe.

# File lib/frame_net/frame.rb, line 266
def is_causative_of
        return self.relations_hash[ "Is Causative of" ].frames
end
is_inchoative_of() click to toggle source

Return Frames in which the receiving frame is an inchoative subframe.

# File lib/frame_net/frame.rb, line 260
def is_inchoative_of
        return self.relations_hash[ "Is Inchoative of" ].frames
end
is_inherited_by() click to toggle source

Return Frames the receiver is inherited by.

# File lib/frame_net/frame.rb, line 202
def is_inherited_by
        return self.relations_hash[ "Is Inherited by" ].frames
end
is_perspectivized_in() click to toggle source

Return Frames which represent different states of affairs of the receiving Frame.

# File lib/frame_net/frame.rb, line 215
def is_perspectivized_in
        return self.relations_hash[ "Is Perspectivized in" ].frames
end
is_preceded_by() click to toggle source

Return Frames the receiver comes after in a series of subframes of another Frame.

# File lib/frame_net/frame.rb, line 254
def is_preceded_by
        return self.relations_hash[ "Is Preceded by" ].frames
end
is_used_by() click to toggle source

Return Frames the receiver is used by.

# File lib/frame_net/frame.rb, line 227
def is_used_by
        return self.relations_hash[ "Is Used by" ].frames
end
perspective_on() click to toggle source

Return Frames in which the receiver is one of several perspectives.

# File lib/frame_net/frame.rb, line 208
def perspective_on
        return self.relations_hash[ "Perspective on" ].frames
end
precedes() click to toggle source

Return Frames the receiver comes before in a series of subframes of another Frame.

# File lib/frame_net/frame.rb, line 247
def precedes
        return self.relations_hash[ "Precedes" ].frames
end
relations_hash() click to toggle source

Return the FrameNet::Frame::Relations this Frame has as a Hash keyed by the Relation's type as a String.

# File lib/frame_net/frame.rb, line 188
def relations_hash
        return self.relations.each_with_object( {} ) do |rel, hash|
                hash[ rel.type ] = rel
        end
end
see_also() click to toggle source

Return the other members of a group of Frames which should be compared to the receiving Frame.

# File lib/frame_net/frame.rb, line 273
def see_also
        return self.relations_hash[ "See also" ].frames
end
subframe_of() click to toggle source

Return Frames the receiver is a subframe of.

# File lib/frame_net/frame.rb, line 233
def subframe_of
        return self.relations_hash[ "Subframe of" ].frames
end
uses() click to toggle source

Return Frames the receiver uses in some capacity.

# File lib/frame_net/frame.rb, line 221
def uses
        return self.relations_hash[ "Uses" ].frames
end