Class: NWordTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
ext/word_tagger/test.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



7
8
9
10
11
12
13
# File 'ext/word_tagger/test.rb', line 7

def setup
  if !defined?($tagger)
    $tagger = Tagger::WordTagger.new
    $tagger.load_tags( File.read('../../tags.txt').split("\n") )
    $tagger.set_words( 4 );
  end
end

#test_basicObject



15
16
17
18
19
20
21
# File 'ext/word_tagger/test.rb', line 15

def test_basic
  timer = Time.now
  text = "This is a sa'mple doc[]ument lets see how cancer ngrams 4 works out for this interesting text!"
  tags = $tagger.execute( text )
  assert_equal ['cancer','work'], tags
  puts "Duration: #{Time.now - timer} sec"
end

#test_ngram_size3Object



23
24
25
26
27
28
29
# File 'ext/word_tagger/test.rb', line 23

def test_ngram_size3
  timer = Time.now
  text = "This body of text contains something like ventricular septal defect"
  tags = $tagger.execute( text )
  assert_equal ['ventricular septal defect'], tags
  puts "Duration: #{Time.now - timer} sec"
end