Class: NCBO::Parser::Annotator

Inherits:
BaseParser show all
Defined in:
lib/ncbo_annotator/parser.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseParser

#parse_xml, #safe_to_i

Constructor Details

#initialize(results) ⇒ Annotator

Returns a new instance of Annotator.



20
21
22
23
# File 'lib/ncbo_annotator/parser.rb', line 20

def initialize(results)
  @root = "/success/data/annotatorResultBean"
  @results = parse_xml(results)
end

Class Method Details

.parse_included_ontologies(ontologies) ⇒ Object



38
39
40
# File 'lib/ncbo_annotator/parser.rb', line 38

def self.parse_included_ontologies(ontologies)
  new(ontologies).parse_included_ontologies
end

.parse_results(results) ⇒ Object



25
26
27
# File 'lib/ncbo_annotator/parser.rb', line 25

def self.parse_results(results)
  new(results).parse_results
end

.parse_semantic_types(semantic_types) ⇒ Object



48
49
50
# File 'lib/ncbo_annotator/parser.rb', line 48

def self.parse_semantic_types(semantic_types)
  new(semantic_types).parse_semantic_types
end

Instance Method Details

#parse_included_ontologiesObject



42
43
44
45
46
# File 'lib/ncbo_annotator/parser.rb', line 42

def parse_included_ontologies
  @root = "/success/data/list"
  ontologies = parse_ontologies("ontologyBean")
  ontologies.delete_if {|a| a[:status] != 28}
end

#parse_resultsObject



29
30
31
32
33
34
35
36
# File 'lib/ncbo_annotator/parser.rb', line 29

def parse_results
  @result = AnnotatorResult.new
  @result.id = @results.find_first(@root + "/resultID").content
  @result.statistics = parse_statistics
  @result.annotations = parse_annotations
  @result.ontologies = parse_ontologies
  @result
end

#parse_semantic_typesObject



52
53
54
# File 'lib/ncbo_annotator/parser.rb', line 52

def parse_semantic_types
  _parse_semantic_types(@results.find_first("/success/data/list"))
end