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

Class Method Details

.initObject



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

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

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



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

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



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

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