You are here

function porterstemmer_step2 in Porter-Stemmer 7

Same name and namespace in other branches
  1. 6.2 porterstemmer.module \porterstemmer_step2()

Step 2 of algorithm: misc endings in region R1.

Parameters

string $word: Word to stem, modified in place if successful.

int $r1: Position of start of R1 region in word.

Return value

bool TRUE if it is time to stop stemming, FALSE to continue.

2 calls to porterstemmer_step2()
PorterStemmerInternalsUnitTest::testGeology in ./porterstemmer.test
Test internal steps on the word "geology".
porterstemmer_stem in includes/standard-stemmer.inc
Stems a word, using the Porter Stemmer 2 algorithm.

File

includes/standard-stemmer.inc, line 423
This is an implementation of the Porter 2 Stemming algorithm.

Code

function porterstemmer_step2(&$word, $r1) {
  $tmp = $word;
  $didit = FALSE;

  // Search for the longest of these suffixes, and if found in R1, replace.
  porterstemmer_suffix($tmp, 'ational', 'ate', $didit, NULL, $r1 + 7) or porterstemmer_suffix($tmp, 'fulness', 'ful', $didit, NULL, $r1 + 7) or porterstemmer_suffix($tmp, 'iveness', 'ive', $didit, NULL, $r1 + 7) or porterstemmer_suffix($tmp, 'ization', 'ize', $didit, NULL, $r1 + 7) or porterstemmer_suffix($tmp, 'ousness', 'ous', $didit, NULL, $r1 + 7) or porterstemmer_suffix($tmp, 'biliti', 'ble', $didit, NULL, $r1 + 6) or porterstemmer_suffix($tmp, 'lessli', 'less', $didit, NULL, $r1 + 6) or porterstemmer_suffix($tmp, 'tional', 'tion', $didit, NULL, $r1 + 6) or porterstemmer_suffix($tmp, 'aliti', 'al', $didit, NULL, $r1 + 5) or porterstemmer_suffix($tmp, 'ation', 'ate', $didit, NULL, $r1 + 5) or porterstemmer_suffix($tmp, 'alism', 'al', $didit, NULL, $r1 + 5) or porterstemmer_suffix($tmp, 'entli', 'ent', $didit, NULL, $r1 + 5) or porterstemmer_suffix($tmp, 'fulli', 'ful', $didit, NULL, $r1 + 5) or porterstemmer_suffix($tmp, 'iviti', 'ive', $didit, NULL, $r1 + 5) or porterstemmer_suffix($tmp, 'ousli', 'ous', $didit, NULL, $r1 + 5) or porterstemmer_suffix($tmp, 'abli', 'able', $didit, NULL, $r1 + 4) or porterstemmer_suffix($tmp, 'alli', 'al', $didit, NULL, $r1 + 4) or porterstemmer_suffix($tmp, 'ator', 'ate', $didit, NULL, $r1 + 4) or porterstemmer_suffix($tmp, 'anci', 'ance', $didit, NULL, $r1 + 4) or porterstemmer_suffix($tmp, 'enci', 'ence', $didit, NULL, $r1 + 4) or porterstemmer_suffix($tmp, 'izer', 'ize', $didit, NULL, $r1 + 4) or porterstemmer_suffix($tmp, 'bli', 'ble', $didit, NULL, $r1 + 3) or porterstemmer_suffix($tmp, 'ogi', 'og', $didit, '/logi$/', $r1 + 3) or porterstemmer_suffix($tmp, 'li', '', $didit, '/' . PORTERSTEMMER_LI_END . 'li$/', $r1 + 2);
  return porterstemmer_step_ending($word, $tmp);
}