protected function Porter2::R in Search API 8
Determines the start of a certain "R" region.
R is a region after the first non-vowel following a vowel, or end of word.
Parameters
int $type: (optional) 1 or 2. If 2, then calculate the R after the R1.
Return value
int The R position.
1 call to Porter2::R()
- Porter2::__construct in src/
Plugin/ search_api/ processor/ Resources/ Porter2.php - Constructs a SearchApiPorter2 object.
File
- src/
Plugin/ search_api/ processor/ Resources/ Porter2.php, line 493
Class
- Porter2
- Implements the Porter2 stemming algorithm.
Namespace
Drupal\search_api\Plugin\search_api\processor\ResourcesCode
protected function R($type = 1) {
$inc = 1;
if ($type === 2) {
$inc = $this->r1;
}
elseif ($this
->length() > 5) {
$prefix_5 = substr($this->word, 0, 5);
if ($prefix_5 === 'gener' || $prefix_5 === 'arsen') {
return 5;
}
if ($this
->length() > 6 && substr($this->word, 0, 6) === 'commun') {
return 6;
}
}
while ($inc <= $this
->length()) {
if (!$this
->isVowel($inc) && $this
->isVowel($inc - 1)) {
$position = $inc;
break;
}
$inc++;
}
if (!isset($position)) {
$position = $this
->length();
}
else {
// We add one, as this is the position AFTER the first non-vowel.
$position++;
}
return $position;
}