Class: SimpleBioC::Passage
- Inherits:
-
Object
- Object
- SimpleBioC::Passage
- Defined in:
- lib/simple_bioc/passage.rb
Instance Attribute Summary collapse
-
#annotations ⇒ Object
Returns the value of attribute annotations.
-
#document ⇒ Object
readonly
Returns the value of attribute document.
-
#infons ⇒ Object
Returns the value of attribute infons.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#relations ⇒ Object
Returns the value of attribute relations.
-
#sentences ⇒ Object
Returns the value of attribute sentences.
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
- #all_annotations(ret) ⇒ Object
- #all_relations(ret) ⇒ Object
- #all_texts ⇒ Object
- #each_relation ⇒ Object
- #find_node(id) ⇒ Object
-
#initialize(parent) ⇒ Passage
constructor
A new instance of Passage.
- #to_s ⇒ Object
Constructor Details
#initialize(parent) ⇒ Passage
Returns a new instance of Passage.
6 7 8 9 10 11 12 |
# File 'lib/simple_bioc/passage.rb', line 6 def initialize(parent) @infons = {} @sentences = [] @annotations = [] @relations = [] @document = parent end |
Instance Attribute Details
#annotations ⇒ Object
Returns the value of attribute annotations.
3 4 5 |
# File 'lib/simple_bioc/passage.rb', line 3 def annotations @annotations end |
#document ⇒ Object (readonly)
Returns the value of attribute document.
4 5 6 |
# File 'lib/simple_bioc/passage.rb', line 4 def document @document end |
#infons ⇒ Object
Returns the value of attribute infons.
3 4 5 |
# File 'lib/simple_bioc/passage.rb', line 3 def infons @infons end |
#offset ⇒ Object
Returns the value of attribute offset.
3 4 5 |
# File 'lib/simple_bioc/passage.rb', line 3 def offset @offset end |
#relations ⇒ Object
Returns the value of attribute relations.
3 4 5 |
# File 'lib/simple_bioc/passage.rb', line 3 def relations @relations end |
#sentences ⇒ Object
Returns the value of attribute sentences.
3 4 5 |
# File 'lib/simple_bioc/passage.rb', line 3 def sentences @sentences end |
#text ⇒ Object
Returns the value of attribute text.
3 4 5 |
# File 'lib/simple_bioc/passage.rb', line 3 def text @text end |
Instance Method Details
#all_annotations(ret) ⇒ Object
37 38 39 40 |
# File 'lib/simple_bioc/passage.rb', line 37 def all_annotations(ret) @annotations.each{|a| ret << a} @sentences.each{|s| s.all_annotations(ret)} end |
#all_relations(ret) ⇒ Object
42 43 44 45 |
# File 'lib/simple_bioc/passage.rb', line 42 def all_relations(ret) @relations.each{|r| ret << r} @sentences.each{|s| s.all_relations(ret)} end |
#all_texts ⇒ Object
32 33 34 35 |
# File 'lib/simple_bioc/passage.rb', line 32 def all_texts return text unless self.text.nil? @sentences.map{|s| s.text}.join(" ") end |
#each_relation ⇒ Object
27 28 29 30 |
# File 'lib/simple_bioc/passage.rb', line 27 def each_relation @relations.each{|r| yield r} @sentences.each{|s| s.each_relation{|r| yield r}} end |
#find_node(id) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/simple_bioc/passage.rb', line 18 def find_node(id) (@relations+@annotations).each{|n| return n if n.id == id} @sentences.each do |s| ret = s.find_node(id) return ret unless ret.nil? end nil end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/simple_bioc/passage.rb', line 14 def to_s "Passage @#{@offset}: #{@text}" end |