protected function stemPluralWord($plural)
{
preg_match('/^(.*)-(.*)$/', $plural, $words);
if (!isset($words[1]) || !isset($words[2])) {
return $plural;
}
// malaikat-malaikat-nya -> malaikat malaikat-nya
$suffix = $words[2];
if (in_array($suffix, array('ku', 'mu', 'nya', 'lah', 'kah', 'tah', 'pun')) && preg_match('/^(.*)-(.*)$/', $words[1], $words)) {
$words[2] .= '-' . $suffix;
}
// berbalas-balasan -> balas
$rootWord1 = $this->stemSingularWord($words[1]);
$rootWord2 = $this->stemSingularWord($words[2]);
// meniru-nirukan -> tiru
if (!$this->dictionary->contains($words[2]) && $rootWord2 === $words[2]) {
$rootWord2 = $this->stemSingularWord('me' . $words[2]);
}
if ($rootWord1 == $rootWord2) {
return $rootWord1;
} else {
return $plural;
}
}