You are here

function PorterStemmerInternalsUnitTest::testGeology in Porter-Stemmer 7

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

Test internal steps on the word "geology".

File

./porterstemmer.test, line 693
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 testGeology() {
  $r1 = 0;
  $r2 = 0;
  $word = 'geology';
  variable_set('minimum_word_size', 2);
  porterstemmer_too_short('', TRUE);
  porterstemmer_prestemming($word, $r1, $r2);

  // Test calculation of R1 and R2
  $this
    ->assertEqual($r1, 4, "R1 for geology should be 4, was {$r1}", 'Stemmer steps');
  $this
    ->assertEqual($r2, 6, "R2 for geology should be 6, was {$r2}", 'Stemmer steps');

  // Test step 1c of the algorithm
  porterstemmer_step1c($word);
  $this
    ->assertEqual($word, 'geologi', "Step1c should be geologi, was {$word}", 'Stemmer steps');

  // Test step 2 of the algorithm
  porterstemmer_step2($word, $r1);
  $this
    ->assertEqual($word, 'geolog', "Step2 should be geolog, was {$word}", 'Stemmer steps');
}