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.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/frame_net/frame/element.rb', line 48 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
79 80 81 |
# File 'lib/frame_net/frame/element.rb', line 79 def abbrev @abbrev end |
#background_color ⇒ Object Also known as: bgColor
The Element’s background color when displayed in a visual medium
100 101 102 |
# File 'lib/frame_net/frame/element.rb', line 100 def background_color @background_color end |
#core_type ⇒ Object Also known as: coreType
The Element’s core type
89 90 91 |
# File 'lib/frame_net/frame/element.rb', line 89 def core_type @core_type end |
#creation_time ⇒ Object Also known as: cDate
The Element’s creation time as a Time object
83 84 85 |
# File 'lib/frame_net/frame/element.rb', line 83 def creation_time @creation_time end |
#definition ⇒ Object
The FrameNet::Definition associated with this Element (if one exists)
106 107 108 |
# File 'lib/frame_net/frame/element.rb', line 106 def definition @definition end |
#foreground_color ⇒ Object Also known as: fgColor
The Element’s foreground color when displayed in a visual medium
94 95 96 |
# File 'lib/frame_net/frame/element.rb', line 94 def foreground_color @foreground_color end |
#id ⇒ Object
The Element’s id
71 72 73 |
# File 'lib/frame_net/frame/element.rb', line 71 def id @id end |
#name ⇒ Object
The Element’s name
75 76 77 |
# File 'lib/frame_net/frame/element.rb', line 75 def name @name end |
#semantic_type ⇒ Object
The FrameNet::SemanticType associated with this Element (if one exists)
110 111 112 |
# File 'lib/frame_net/frame/element.rb', line 110 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).
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/frame_net/frame/element.rb', line 25 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)
19 20 21 |
# File 'lib/frame_net/frame/element.rb', line 19 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.
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/frame_net/frame/element.rb', line 114 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 |