Class: NCBO::Annotator
- Inherits:
-
Object
- Object
- NCBO::Annotator
- Defined in:
- lib/ncbo_annotator.rb
Class Method Summary collapse
- .annotate(text, options = {}) ⇒ Object
- .ontologies(options) ⇒ Object
- .semantic_types(options) ⇒ Object
Instance Method Summary collapse
- #annotate(text = nil, options = {}) ⇒ Object
-
#initialize(args = {}) ⇒ Annotator
constructor
A new instance of Annotator.
- #ontologies ⇒ Object
- #options ⇒ Object
- #semantic_types ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Annotator
Returns a new instance of Annotator.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ncbo_annotator.rb', line 10 def initialize(args = {}) @options = {} @options[:annotator_location] = "http://rest.bioontology.org/obs" @options[:filterNumber] = true @options[:isStopWordsCaseSensitive] = true @options[:isVirtualOntologyId] = true @options[:levelMax] = 0 @options[:longestOnly] = false @options[:ontologiesToExpand] = [] @options[:ontologiesToKeepInResult] = [] @options[:mappingTypes] = [] @options[:minTermSize] = 3 @options[:scored] = true @options[:semanticTypes] = [] @options[:stopWords] = [] @options[:wholeWordOnly] = false @options[:withDefaultStopWords] = false @options[:withSynonyms] = true @options.merge!(args) @ontologies = nil # Check to make sure mappingTypes are capitalized fix_params raise ArgumentError, ":apikey is required, you can obtain one at http://bioportal.bioontology.org/accounts/new" if @options[:apikey].nil? end |
Class Method Details
.annotate(text, options = {}) ⇒ Object
40 41 42 43 |
# File 'lib/ncbo_annotator.rb', line 40 def self.annotate(text, = {}) [:textToAnnotate] = text new().annotate end |
.ontologies(options) ⇒ Object
56 57 58 |
# File 'lib/ncbo_annotator.rb', line 56 def self.ontologies() new().ontologies end |
.semantic_types(options) ⇒ Object
69 70 71 |
# File 'lib/ncbo_annotator.rb', line 69 def self.semantic_types() new().semantic_types end |
Instance Method Details
#annotate(text = nil, options = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ncbo_annotator.rb', line 45 def annotate(text = nil, = {}) @options[:textToAnnotate] = text unless text.nil? @options.merge!() unless .empty? fix_params raise ArgumentError, ":textToAnnotate must be included" if @options[:textToAnnotate].nil? result_xml = annotate_post Parser::Annotator.parse_results(result_xml) end |
#ontologies ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/ncbo_annotator.rb', line 60 def ontologies if @ontologies.nil? ontologies_xml = open("#{@options[:annotator_location]}/ontologies?apikey=#{@options[:apikey]}").read @ontologies = Parser::Annotator.parse_included_ontologies(ontologies_xml) else @ontologies end end |
#options ⇒ Object
82 83 84 |
# File 'lib/ncbo_annotator.rb', line 82 def @options end |
#semantic_types ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/ncbo_annotator.rb', line 73 def semantic_types if @semantic_types.nil? semantic_types_xml = open("#{@options[:annotator_location]}/semanticTypes?apikey=#{@options[:apikey]}").read @semantic_types = Parser::Annotator.parse_semantic_types(semantic_types_xml) else @semantic_types end end |