You are here

function PorterStemmerInternalsUnitTest::testStemLength3UnitTest in Porter-Stemmer 7

Same name and namespace in other branches
  1. 6.2 porterstemmer.test \PorterStemmerInternalsUnitTest::testStemLength3UnitTest()

Verify that short words are not stemmed, and longer ones are.

File

./porterstemmer.test, line 554
Tests for the Porter Stemmer module. By Jennifer Hodgdon of Poplar ProductivityWare, www.poplarware.com Unit tests are based on sample words from http://snowball.tartarus.org/algorithms/english/stemmer.html which are stored in a separate file…

Class

PorterStemmerInternalsUnitTest
Unit tests for Porter Stemmer - Stemming internals.

Code

function testStemLength3UnitTest() {

  // Words 3 letters or less should not be stemmed if min word length is 3
  variable_set('minimum_word_size', 3);
  porterstemmer_too_short('', TRUE);
  $words = array(
    'a' => 'a',
    'at' => 'at',
    'say' => 'say',
    'fished' => 'fish',
    'saying' => 'say',
  );
  foreach ($words as $in => $out) {
    $stem = porterstemmer_stem($in);
    $this
      ->assertEqual($out, $stem, "Stemming length 3 test for {$in} gives {$out} (was {$stem})", t('Stemming length'));
  }
}