Class: FrameNet::Frame::Element
- Inherits:
-
Object
- Object
- FrameNet::Frame::Element
- Defined in:
- lib/frame_net/frame/element.rb
Overview
Frame elements of a FrameNet::Frame
References:
Constant Summary collapse
- XPATH =
The xpath of the FEs of a frame
'//fn:frame/fn:FE'
Instance Attribute Summary collapse
-
#abbrev ⇒ Object
The Element’s abbreviation.
-
#background_color ⇒ Object
(also: #bgColor)
The Element’s background color when displayed in a visual medium.
-
#core_type ⇒ Object
(also: #coreType)
The Element’s core type.
-
#creation_time ⇒ Object
(also: #cDate)
The Element’s creation time as a Time object.
-
#definition ⇒ Object
The FrameNet::Definition associated with this Element (if one exists).
-
#foreground_color ⇒ Object
(also: #fgColor)
The Element’s foreground color when displayed in a visual medium.
-
#id ⇒ Object
The Element’s id.
-
#name ⇒ Object
The Element’s name.
-
#semantic_type ⇒ Object
The FrameNet::SemanticType associated with this Element (if one exists).
Class Method Summary collapse
-
.from_fe_node(node) ⇒ Object
Construct an Element from the given
node(a LibXML::XML::Node). -
.from_frame_data(doc) ⇒ Object
Construct one or more Elements from the FEs of the specified
doc(a LibXML::XML::Document parsed from the XML for a frame).
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Element
constructor
Create a new frame Element.
-
#inspect ⇒ Object
Return the Element as a human-readable string suitable for debugging.
Constructor Details
#initialize {|_self| ... } ⇒ Element
Create a new frame Element. If a block is given, yield the new object to it so its attributes can be set.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/frame_net/frame/element.rb', line 49 def initialize # :yields: self @id = id @name = name @core_type = core_type @abbrev = nil @creation_time = nil @foreground_color = nil @background_color = nil @definition = nil @semantic_type = nil yield( self ) if block_given? end |
Instance Attribute Details
#abbrev ⇒ Object
The Element’s abbreviation
80 81 82 |
# File 'lib/frame_net/frame/element.rb', line 80 def abbrev @abbrev end |
#background_color ⇒ Object Also known as: bgColor
The Element’s background color when displayed in a visual medium
101 102 103 |
# File 'lib/frame_net/frame/element.rb', line 101 def background_color @background_color end |
#core_type ⇒ Object Also known as: coreType
The Element’s core type
90 91 92 |
# File 'lib/frame_net/frame/element.rb', line 90 def core_type @core_type end |
#creation_time ⇒ Object Also known as: cDate
The Element’s creation time as a Time object
84 85 86 |
# File 'lib/frame_net/frame/element.rb', line 84 def creation_time @creation_time end |
#definition ⇒ Object
The FrameNet::Definition associated with this Element (if one exists)
107 108 109 |
# File 'lib/frame_net/frame/element.rb', line 107 def definition @definition end |
#foreground_color ⇒ Object Also known as: fgColor
The Element’s foreground color when displayed in a visual medium
95 96 97 |
# File 'lib/frame_net/frame/element.rb', line 95 def foreground_color @foreground_color end |
#id ⇒ Object
The Element’s id
72 73 74 |
# File 'lib/frame_net/frame/element.rb', line 72 def id @id end |
#name ⇒ Object
The Element’s name
76 77 78 |
# File 'lib/frame_net/frame/element.rb', line 76 def name @name end |
#semantic_type ⇒ Object
The FrameNet::SemanticType associated with this Element (if one exists)
111 112 113 |
# File 'lib/frame_net/frame/element.rb', line 111 def semantic_type @semantic_type end |
Class Method Details
.from_fe_node(node) ⇒ Object
Construct an Element from the given node (a LibXML::XML::Node).
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/frame_net/frame/element.rb', line 26 def self::from_fe_node( node ) return new do |elem| elem.id = Integer( node['ID'] ) elem.name = node['name'].to_sym elem.core_type = node['coreType'] elem.abbrev = node['abbrev'] elem.creation_time = FrameNet.parse_time( node['cDate'] ) elem.foreground_color = node['fgColor'] elem.background_color = node['bgColor'] if def_node = node.find_first( './fn:definition' ) elem.definition = FrameNet::Definition.from_node( def_node ) end if st_node = node.find_first( './fn:semType' ) elem.semantic_type = FrameNet::SemanticType.from_node( st_node ) end end end |
.from_frame_data(doc) ⇒ Object
Construct one or more Elements from the FEs of the specified doc (a LibXML::XML::Document parsed from the XML for a frame)
20 21 22 |
# File 'lib/frame_net/frame/element.rb', line 20 def self::from_frame_data( doc ) return doc.find( XPATH ).map {|node| self.from_fe_node(node) } end |
Instance Method Details
#inspect ⇒ Object
Return the Element as a human-readable string suitable for debugging.
115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/frame_net/frame/element.rb', line 115 def inspect return %{#<%p:%#016x %s%s(%s) [%d] "%s">} % [ self.class, self.object_id * 2, self.name || "(Unnamed)", self.semantic_type ? ":#{self.semantic_type.name}" : '', self.core_type, self.id || 0, self.definition ? self.definition.stripped_content : '', ] end |