To edit pages or tickets please login with username/password: aaf/aaf

Changeset 76

Show
Ignore:
Timestamp:
08/23/06 09:35:48 (2 years ago)
Author:
jk
Message:

r258@monsoon: jk | 2006-08-23 11:14:27 +0200
unit test for analysis ferret bug

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/demo/test/unit/comment_test.rb

    r60 r76  
    131131    comment.destroy 
    132132    comment2.destroy 
    133    end 
     133  end 
     134 
     135  # fixed with Ferret 0.9.6 
     136  def test_stopwords_ferret_bug  
     137    i = Ferret::Index::Index.new( 
     138            :occur_default => Ferret::Search::BooleanClause::Occur::MUST, 
     139            :default_search_field => '*' 
     140            ) 
     141    d = Ferret::Document::Document.new 
     142    d << Ferret::Document::Field.new('id', '1',  
     143                                     Ferret::Document::Field::Store::YES, 
     144                                     Ferret::Document::Field::Index::UNTOKENIZED, 
     145                                     Ferret::Document::Field::TermVector::NO, 
     146                                     false, 1.0) 
     147    d << Ferret::Document::Field.new('content', 'Move or shake',  
     148                                     Ferret::Document::Field::Store::NO, 
     149                                     Ferret::Document::Field::Index::TOKENIZED, 
     150                                     Ferret::Document::Field::TermVector::NO, 
     151                                     false, 1.0) 
     152    i << d 
     153    hits = i.search 'move nothere shake' 
     154    assert_equal 0,hits.size 
     155    hits = i.search 'move shake' 
     156    assert_equal 1,hits.size 
     157    hits = i.search 'move or shake' 
     158    assert_equal 1,hits.size 
     159    hits = i.search 'move and shake' 
     160    assert_equal 1,hits.size 
     161  end 
     162 
     163  def test_stopwords 
     164    comment = Comment.create( :author => 'john doe', :content => 'Move or shake' ) 
     165    ['move shake', 'Move shake', 'move Shake'].each do |q| 
     166      comments_from_ferret = Comment.find_by_contents(q) 
     167      assert_equal comment, comments_from_ferret.first, "query #{q} failed" 
     168    end 
     169 
     170    comments_from_ferret = Comment.find_by_contents('Move or shake') 
     171    assert_equal 1, comments_from_ferret.size 
     172    assert_equal comment, comments_from_ferret.first 
     173    comment.destroy 
     174  end 
    134175 
    135176end 

To edit pages or tickets please login with username/password: aaf/aaf