You are here

function m in Porter-Stemmer 6

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

What, you mean it's not obvious from the name?

m() measures the number of consonant sequences in $str. if c is a consonant sequence and v a vowel sequence, and <..> indicates arbitrary presence,

<c><v> gives 0 <c>vc<v> gives 1 <c>vcvc<v> gives 2 <c>vcvcvc<v> gives 3

Parameters

string $str The string to return the m count for:

Return value

int The m count

3 calls to m()
replace in ./porterstemmer.module
Replaces the first string with the second, at the end of the string. If third arg is given, then the preceding string must match that m count at least.
step1ab in ./porterstemmer.module
Step 1
step5 in ./porterstemmer.module
Step 5

File

./porterstemmer.module, line 378

Code

function m($str) {
  $c = regex_consonant;
  $v = regex_vowel;
  $str = preg_replace("#^{$c}+#", '', $str);
  $str = preg_replace("#{$v}+\$#", '', $str);
  preg_match_all("#({$v}+{$c}+)#", $str, $matches);
  return count($matches[1]);
}