Module: Linnaeus

Defined in:
lib/rbbt/ner/linnaeus.rb

Constant Summary collapse

ARGS =
["--properties", Rbbt.software.opt.Linnaeus["species-proxy/properties.conf"].find]

Class Method Summary collapse

Class Method Details

.initObject



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 $!.message =~ /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
# File 'lib/rbbt/ner/linnaeus.rb', line 29

def self.match(text)

  init unless defined? @@Matcher

  @@Matcher.match(text).toArray().collect do |mention|
    NamedEntity.setup(mention.text(), mention.start(), "Organism", mention.ids(), mention.probabilities())
  end
end