Class: ChemicalTagger

Inherits:
NER
  • Object
show all
Defined in:
lib/rbbt/ner/chemical_tagger.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NER

#entities, #extract, #initialize

Constructor Details

This class inherits a constructor from NER

Class Method Details

.initObject



9
10
11
12
13
# File 'lib/rbbt/ner/chemical_tagger.rb', line 9

def self.init
  ENV["CLASSPATH"] = [ENV["CLASSPATH"].split(":"), Rbbt.software.opt.ChemicalTagger.produce.glob("*.jar").first].reverse * ":"
  Rjb::load(nil, jvmargs = ['-Xms1G','-Xmx2G']) unless Rjb.loaded?
  @@RbbtChemicalTagger ||= Rjb::import('RbbtChemicalTagger')
end

.match(text, type = nil, memm = false) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rbbt/ner/chemical_tagger.rb', line 15

def self.match(text,  type = nil, memm =  false)
  self.init

  return [] if text.nil? or text.strip.empty?

  begin
    matches = @@RbbtChemicalTagger.match(text)
  rescue
    Log.exception $!
    return []
  end

  matches.collect do |mention|
    offset = text.index mention
    NamedEntity.setup mention, offset, "Chemical Mention", nil, nil
  end
end

Instance Method Details

#match(*args) ⇒ Object



33
34
35
# File 'lib/rbbt/ner/chemical_tagger.rb', line 33

def match(*args)
  ChemicalTagger.match(*args)
end