1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- declare(strict_types = 1);
- 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;
- }
- }
|