function step4 in Porter-Stemmer 5
Same name and namespace in other branches
- 6 porterstemmer.module \step4()
Step 4
Parameters
string $word Word to stem:
1 call to step4()
- stem in ./
porterstemmer.module - Stems a word. Simple huh?
File
- ./
porterstemmer.module, line 239
Code
function step4($word) {
switch (substr($word, -2, 1)) {
case 'a':
replace($word, 'al', '', 1);
break;
case 'c':
replace($word, 'ance', '', 1) or replace($word, 'ence', '', 1);
break;
case 'e':
replace($word, 'er', '', 1);
break;
case 'i':
replace($word, 'ic', '', 1);
break;
case 'l':
replace($word, 'able', '', 1) or replace($word, 'ible', '', 1);
break;
case 'n':
replace($word, 'ant', '', 1) or replace($word, 'ement', '', 1) or replace($word, 'ment', '', 1) or replace($word, 'ent', '', 1);
break;
case 'o':
if (substr($word, -4) == 'tion' or substr($word, -4) == 'sion') {
replace($word, 'ion', '', 1);
}
else {
replace($word, 'ou', '', 1);
}
break;
case 's':
replace($word, 'ism', '', 1);
break;
case 't':
replace($word, 'ate', '', 1) or replace($word, 'iti', '', 1);
break;
case 'u':
replace($word, 'ous', '', 1);
break;
case 'v':
replace($word, 'ive', '', 1);
break;
case 'z':
replace($word, 'ize', '', 1);
break;
}
return $word;
}