Class: BioInterchange::TextMining::ContentConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/biointerchange/textmining/content_connection.rb

Constant Summary collapse

UNSPECIFIED =

Constants that describe content connection type.

0
EQUIVALENCE =
1
SUBCLASS =
2
THEME =
3
SPECULATION =
4
NEGATION =
5

Instance Method Summary collapse

Constructor Details

#initialize(content1, content2, type = UNSPECIFIED, process = nil) ⇒ ContentConnection

Creates a new document content connection representation between specific document content.

content1

document content 1

content2

document content 2

type

classifaction of the connection between the two document content objects



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/biointerchange/textmining/content_connection.rb', line 18

def initialize(content1, content2, type = UNSPECIFIED, process = nil)
  if content1.nil? and content2.nil?
    raise BioInterchange::Exceptions::ImplementationModelError, 'Content1 and Content2 can not both be nil'
  elsif ( (! content1.kind_of?(BioInterchange::TextMining::Content)) && (! content1.kind_of?(BioInterchange::TextMining::ContentConnection)) && (! content1.nil?) )
    raise BioInterchange::Exceptions::ImplementationModelError, 'Content1 has to be of kind BioInterchange::TextMining::Content or kind BioInterchange::TextMining::ContentConnection'  
  elsif ( (! content2.kind_of?(BioInterchange::TextMining::Content)) && (! content2.kind_of?(BioInterchange::TextMining::ContentConnection)) && (! content2.nil?) )
    raise BioInterchange::Exceptions::ImplementationModelError, 'Content2 has to be of kind BioInterchange::TextMining::Content or kind BioInterchange::TextMining::ContentConnection'  
  end
  @content1 = content1
  @content2 = content2
  @type = type
  @process = process
end

Instance Method Details

#content1Object

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



40
41
42
# File 'lib/biointerchange/textmining/content_connection.rb', line 40

def content1
  @content1
end

#content2Object

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



45
46
47
# File 'lib/biointerchange/textmining/content_connection.rb', line 45

def content2
  @content2
end

#processObject

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



55
56
57
# File 'lib/biointerchange/textmining/content_connection.rb', line 55

def process
  @process
end

#setContext(context) ⇒ Object

Sets the context of this content.

context

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



35
36
37
# File 'lib/biointerchange/textmining/content_connection.rb', line 35

def setContext(context)
  @context = context
end

#typeObject

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



50
51
52
# File 'lib/biointerchange/textmining/content_connection.rb', line 50

def type
  @type
end

#uriObject

Returns a URI that identifies this content.



60
61
62
63
64
65
66
67
68
69
# File 'lib/biointerchange/textmining/content_connection.rb', line 60

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 = '-'
  c1 = '-'
  c2 = '-'
  process = "(#{@process.uri.sub(/^.*?:\/\//, '')})" if @process
  c1 = "#{@content1.uri.sub(/^.*?:\/\//, '')}" if @content1
  c2 = "#{@content2.uri.sub(/^.*?:\/\//, '')}" if @content2
  "biointerchange://textmining/content_connection/#{@context.uri.sub(/^.*?:\/\//, '')}/#{c1},#{c2},#{@type},#{process}"
end