Sastrawi\Stemmer\Stemmer::stemPluralWord PHP Method

stemPluralWord() protected method

Asian J. (2007) “Effective Techniques for Indonesian Text Retrieval” page 76-77.
protected stemPluralWord ( string $plural ) : string
$plural string the word to stem, e.g : bersama-sama
return string common stem form, e.g : sama
    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;
        }
    }