Sha256: 55130078e9f9deb2c30772d205ae51c8d306e03deca2c9b9cd8cbebba98c005d

Contents?: true

Size: 1.99 KB

Versions: 12

Compression:

Stored size: 1.99 KB

Contents

module BioInterchange::TextMining

class Content

  # Constants that describe content types.
  UNSPECIFIED =  0
  DOCUMENT    =  1
  PAGE        =  2
  TITLE       =  3
  AUTHOR      =  4
  ABSTRACT    =  5
  SECTION     =  6
  PARAGRAPH   =  7
  SENTENCE    =  8
  PHRASE      =  9
  WORD        = 10
  CHARACTER   = 11

  # 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
  def initialize(offset, length, type = UNSPECIFIED, process = nil)
    @offset = offset
    @length = length
    @type = type
    @process = process
  end

  # Sets the context of this content.
  #
  # +context+:: a +BioInterchange::TextMining::Document+ or +BioInterchange::TextMining::Content+ instance in which this content is enclosed in
  def setContext(context)
    @context = context
  end

  # Returns the offset of the content as absolute position within the document.
  def offset
    @offset
  end

  # Returns the length of the content, which is measured in characters.
  def length
    @length
  end

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

  # Returns the process associated with this content, if previously provided, or nil otherwise.
  def process
    @process
  end

  # Returns a URI that identifies this content.
  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


end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
biointerchange-1.0.8 lib/biointerchange/textmining/content.rb
biointerchange-1.0.7 lib/biointerchange/textmining/content.rb
biointerchange-1.0.6 lib/biointerchange/textmining/content.rb
biointerchange-1.0.5 lib/biointerchange/textmining/content.rb
biointerchange-1.0.4 lib/biointerchange/textmining/content.rb
biointerchange-1.0.2 lib/biointerchange/textmining/content.rb
biointerchange-1.0.1 lib/biointerchange/textmining/content.rb
biointerchange-1.0.0 lib/biointerchange/textmining/content.rb
biointerchange-0.2.2 lib/biointerchange/textmining/content.rb
biointerchange-0.2.1 lib/biointerchange/textmining/content.rb
biointerchange-0.2.0 lib/biointerchange/textmining/content.rb
biointerchange-0.1.3 lib/biointerchange/textmining/content.rb