Class: BioInterchange::TextMining::Content
- Inherits:
-
Object
- Object
- BioInterchange::TextMining::Content
- Defined in:
- lib/biointerchange/textmining/content.rb
Constant Summary collapse
- UNSPECIFIED =
Constants that describe content types.
0
- DOCUMENT =
1
- PAGE =
2
- TITLE =
3
- AUTHOR =
4
- ABSTRACT =
5
- SECTION =
6
- PARAGRAPH =
7
- SENTENCE =
8
- PHRASE =
9
- WORD =
10
- CHARACTER =
11
Instance Method Summary collapse
-
#initialize(offset, length, type = UNSPECIFIED, process = nil) ⇒ Content
constructor
Creates a new document content representation at a specific location of the document.
-
#length ⇒ Object
Returns the length of the content, which is measured in characters.
-
#offset ⇒ Object
Returns the offset of the content as absolute position within the document.
-
#process ⇒ Object
Returns the process associated with this content, if previously provided, or nil otherwise.
-
#setContext(context) ⇒ Object
Sets the context of this content.
-
#type ⇒ Object
Returns the type of the content, if known, or +BioInterchange::TextMining::Content::UNSPECIFIED otherwise.
-
#uri ⇒ Object
Returns a URI that identifies this content.
Constructor Details
#initialize(offset, length, type = UNSPECIFIED, process = nil) ⇒ Content
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
24 25 26 27 28 29 |
# 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 |
Instance Method Details
#length ⇒ Object
Returns the length of the content, which is measured in characters.
44 45 46 |
# File 'lib/biointerchange/textmining/content.rb', line 44 def length @length end |
#offset ⇒ Object
Returns the offset of the content as absolute position within the document.
39 40 41 |
# File 'lib/biointerchange/textmining/content.rb', line 39 def offset @offset end |
#process ⇒ Object
Returns the process associated with this content, if previously provided, or nil otherwise.
54 55 56 |
# File 'lib/biointerchange/textmining/content.rb', line 54 def process @process end |
#setContext(context) ⇒ Object
Sets the context of this content.
context
-
a
BioInterchange::TextMining::Document
orBioInterchange::TextMining::Content
instance in which this content is enclosed in
34 35 36 |
# File 'lib/biointerchange/textmining/content.rb', line 34 def setContext(context) @context = context end |
#type ⇒ Object
Returns the type of the content, if known, or +BioInterchange::TextMining::Content::UNSPECIFIED otherwise.
49 50 51 |
# File 'lib/biointerchange/textmining/content.rb', line 49 def type @type end |
#uri ⇒ Object
Returns a URI that identifies this content.
59 60 61 62 63 64 |
# 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 |