Class: FrameNet::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/frame_net/definition.rb

Overview

A marked-up English language definition from various FrameNet elements

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Definition

Create a new Definition for the specified raw_content.

Yields:

  • (_self)

Yield Parameters:



31
32
33
34
# File 'lib/frame_net/definition.rb', line 31

def initialize
	@content = nil
	yield( self ) if block_given?
end

Instance Attribute Details

#contentObject

The raw (unescaped) content of the definition.



43
44
45
# File 'lib/frame_net/definition.rb', line 43

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)



24
25
26
27
# File 'lib/frame_net/definition.rb', line 24

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)



15
16
17
18
19
# File 'lib/frame_net/definition.rb', line 15

def self::from_node( node )
	return new do |definition|
		definition.content = node.content
	end
end

Instance Method Details

#stripped_contentObject

Return the definition’s content with the XML stripped.



47
48
49
# File 'lib/frame_net/definition.rb', line 47

def stripped_content
	return self.content.gsub( /<.*?>/, '' ).tr( "\n\t ", ' ' ).strip
end