You are here

function step2 in Porter-Stemmer 6

Same name and namespace in other branches
  1. 5 porterstemmer.module \step2()

Step 2

Parameters

string $word Word to stem:

1 call to step2()
stem in ./porterstemmer.module
Stems a word. Simple huh?

File

./porterstemmer.module, line 143

Code

function step2($word) {
  switch (substr($word, -2, 1)) {
    case 'a':
      replace($word, 'ational', 'ate', 0) or replace($word, 'tional', 'tion', 0);
      break;
    case 'c':
      replace($word, 'enci', 'ence', 0) or replace($word, 'anci', 'ance', 0);
      break;
    case 'e':
      replace($word, 'izer', 'ize', 0);
      break;
    case 'g':
      replace($word, 'logi', 'log', 0);
      break;
    case 'l':
      replace($word, 'entli', 'ent', 0) or replace($word, 'ousli', 'ous', 0) or replace($word, 'alli', 'al', 0) or replace($word, 'bli', 'ble', 0) or replace($word, 'eli', 'e', 0);
      break;
    case 'o':
      replace($word, 'ization', 'ize', 0) or replace($word, 'ation', 'ate', 0) or replace($word, 'ator', 'ate', 0);
      break;
    case 's':
      replace($word, 'iveness', 'ive', 0) or replace($word, 'fulness', 'ful', 0) or replace($word, 'ousness', 'ous', 0) or replace($word, 'alism', 'al', 0);
      break;
    case 't':
      replace($word, 'biliti', 'ble', 0) or replace($word, 'aliti', 'al', 0) or replace($word, 'iviti', 'ive', 0);
      break;
  }
  return $word;
}