Class: FrameNet::Definition
- Inherits:
-
Object
- Object
- FrameNet::Definition
- Defined in:
- lib/frame_net/definition.rb
Overview
A marked-up English language definition from various FrameNet elements
Instance Attribute Summary collapse
-
#content ⇒ Object
The raw (unescaped) content of the definition.
Class Method Summary collapse
-
.from_frame_data(document) ⇒ Object
Load a definition from a frame XML
document(a LibXML::XML::Document parsed from frame XML). -
.from_node(node) ⇒ Object
Construct a Definition from the given
node(a LibXML::XML::Node for a definition element).
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Definition
constructor
Create a new Definition for the specified
raw_content. -
#stripped_content ⇒ Object
Return the definition’s content with the XML stripped.
Constructor Details
#initialize {|_self| ... } ⇒ Definition
Create a new Definition for the specified raw_content.
30 31 32 33 |
# File 'lib/frame_net/definition.rb', line 30 def initialize @content = nil yield( self ) if block_given? end |
Instance Attribute Details
#content ⇒ Object
The raw (unescaped) content of the definition.
42 43 44 |
# File 'lib/frame_net/definition.rb', line 42 def content @content end |
Class Method Details
.from_frame_data(document) ⇒ Object
Load a definition from a frame XML document (a LibXML::XML::Document parsed from frame XML)
23 24 25 26 |
# File 'lib/frame_net/definition.rb', line 23 def self::from_frame_data( document ) node = document.find_first( '//fn:definition' ) or return nil return self.from_node( node ) end |
.from_node(node) ⇒ Object
Construct a Definition from the given node (a LibXML::XML::Node for a definition element)
14 15 16 17 18 |
# File 'lib/frame_net/definition.rb', line 14 def self::from_node( node ) return new do |definition| definition.content = node.content end end |
Instance Method Details
#stripped_content ⇒ Object
Return the definition’s content with the XML stripped.
46 47 48 |
# File 'lib/frame_net/definition.rb', line 46 def stripped_content return self.content.gsub( /<.*?>/, '' ).tr( "\n\t ", ' ' ).strip end |