class BioInterchange::TextMining::Content

Constants

ABSTRACT
AUTHOR
CHARACTER
DOCUMENT
PAGE
PARAGRAPH
PHRASE
SECTION
SENTENCE
TITLE
UNSPECIFIED

Constants that describe content types.

WORD

Public Class Methods

new(offset, length, type = UNSPECIFIED, process = nil) click to toggle source

Creates a new document content representation at a specific location of the document.

offset

zero-based offset of the represented content within the document (absolute location within the document)

length

length of the represented content, where a length of zero denotes a boundary between two characters

type

classifaction of the content

# File lib/biointerchange/textmining/content.rb, line 24
def initialize(offset, length, type = UNSPECIFIED, process = nil)
  @offset = offset
  @length = length
  @type = type
  @process = process
end

Public Instance Methods

length() click to toggle source

Returns the length of the content, which is measured in characters.

# File lib/biointerchange/textmining/content.rb, line 44
def length
  @length
end
offset() click to toggle source

Returns the offset of the content as absolute position within the document.

# File lib/biointerchange/textmining/content.rb, line 39
def offset
  @offset
end
process() click to toggle source

Returns the process associated with this content, if previously provided, or nil otherwise.

# File lib/biointerchange/textmining/content.rb, line 54
def process
  @process
end
setContext(context) click to toggle source

Sets the context of this content.

context

a BioInterchange::TextMining::Document or BioInterchange::TextMining::Content instance in which this content is enclosed in

# File lib/biointerchange/textmining/content.rb, line 34
def setContext(context)
  @context = context
end
type() click to toggle source

Returns the type of the content, if known, or +BioInterchange::TextMining::Content::UNSPECIFIED otherwise.

# File lib/biointerchange/textmining/content.rb, line 49
def type
  @type
end
uri() click to toggle source

Returns a URI that identifies this content.

# File lib/biointerchange/textmining/content.rb, line 59
def uri
  raise BioInterchange::Exceptions::ImplementationModelError, 'An URI can only be returned for content with a context (i.e., use setContext(context) first).' unless @context
  process = '-'
  process = "(#{@process.uri.sub(/^.*?:\/\//, '')})" if @process
  "biointerchange://textmining/content/#{@context.uri.sub(/^.*?:\/\//, '')}/#{@offset},#{@length},#{@type},#{process}"
end