Sha256: a61dd06b14da65fa81d0816650680592893f1be883f6768eb78baf609773aea6

Contents?: true

Size: 1.54 KB

Versions: 27

Compression:

Stored size: 1.54 KB

Contents

require File.join(File.expand_path(File.dirname(__FILE__)), '../../test_helper.rb')
require 'rbbt/ner/oscar4'
require 'rbbt/util/tmpfile'
require 'test/unit'

class TestOSCAR4 < Test::Unit::TestCase

  def test_match
    begin
      ner = OSCAR4.new
      str  = "Alternatively, CO2 rearrangement of O-(w-haloalkyl)esters 34 of 2-carboethoxy-N-hydroxypyridine-2-selone affords azonianaphthalenium halides 37 in 79% yield"

      mentions = ner.match(str, "CM")
      good_mentions = ["2-carboethoxy-N-hydroxypyridine-2-selone", "O-(w-haloalkyl)esters"]

      good_mentions.each{|mention| 
        assert(mentions.include? mention)
      }
    rescue
      puts $!.message
      puts $!.backtrace
    end
  end

  def test_ranges
    begin
      ner = OSCAR4.new
      str =<<-EOF 
This sentence talks about 2-carboethoxy-N-hydroxypyridine-2-selone.
This sentence talks about 2-carboethoxy-N-hydroxypyridine-2-selone.
This sentence talks about 2-carboethoxy-N-hydroxypyridine-2-selone.
This sentence talks about 2-carboethoxy-N-hydroxypyridine-2-selone.
This otherone talks about O-(w-haloalkyl)esters.
This otherone talks about O-(w-haloalkyl)esters.
This otherone talks about O-(w-haloalkyl)esters.

This otherone talks about O-(w-haloalkyl)esters.
This otherone talks about O-(w-haloalkyl)esters.
      EOF


      mentions = ner.match(str, "CM", false)

      str_original = str.dup
      mentions.each do |mention|
        str[mention.range] = mention
      end

      assert_equal str_original, str

    rescue
      puts $!.message
      puts $!.backtrace
    end
  end

end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
rbbt-text-1.5.2 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.5.1 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.5.0 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.4.0 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.3.11 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.3.10 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.3.9 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.3.8 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.3.7 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.3.6 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.3.5 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.3.4 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.3.3 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.3.2 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.3.1 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.3.0 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.2.0 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.1.9 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.1.8 test/rbbt/ner/test_oscar4.rb
rbbt-text-1.1.7 test/rbbt/ner/test_oscar4.rb