[PLUGIN][StemWord] Remove the country part from the code. Ignore if no stemmer is found for the given language

This commit is contained in:
Hugo Sales 2021-12-08 21:50:26 +00:00
parent 659ea5cd1f
commit 26b95fae96
No known key found for this signature in database
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -25,13 +25,19 @@ namespace Plugin\StemWord;
use App\Core\Event;
use App\Core\Modules\Plugin;
use Wamania\Snowball\NotFoundException;
use Wamania\Snowball\StemmerFactory;
class StemWord extends Plugin
{
public function onStemWord(string $language, string $word, ?string &$out)
{
$language = explode('_', $language)[0];
try {
$out = StemmerFactory::create($language)->stem($word);
} catch (NotFoundException) {
return Event::next;
}
return Event::stop;
}
}