Module: Linnaeus
- Defined in:
- lib/rbbt/ner/linnaeus.rb
Constant Summary collapse
- ARGS =
["--properties", Rbbt.software.opt.Linnaeus.produce["species-proxy/properties.conf"].find]
Class Method Summary collapse
Class Method Details
.init ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rbbt/ner/linnaeus.rb', line 13 def self.init begin @@ArgParser = Rjb::import('martin.common.ArgParser') @@Args = @@ArgParser.new(ARGS) @@Loggers = Rjb::import('martin.common.Loggers') @@Logger = @@Loggers.getDefaultLogger(@@Args) @@EntityTagger = Rjb::import('uk.ac.man.entitytagger.EntityTagger') @@Matcher = @@EntityTagger.getMatcher(@@Args, @@Logger) rescue if $!. =~ /heap space/i Log.warn "Heap Space seems too low. Make sure Linnaeus is loaded before other Java wrappers so that it has the chance to init the Java Bridge with sufficient heap space" end raise $! end end |
.match(text) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/rbbt/ner/linnaeus.rb', line 29 def self.match(text) init unless defined? @@Matcher @@Matcher.match(text).toArray().collect do |mention| best_id, best_prob = mention.ids().zip(mention.probabilities()).sort_by{|i,p| p.to_f }.last NamedEntity.setup(mention.text(), :offset => mention.start(), :entity_type => "Organism", :code => best_id, :score => best_prob) end end |