[PLUGIN][StemWord] Remove the country part from the code. Ignore if no stemmer is found for the given language
This commit is contained in:
parent
659ea5cd1f
commit
26b95fae96
|
@ -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)
|
||||
{
|
||||
$out = StemmerFactory::create($language)->stem($word);
|
||||
$language = explode('_', $language)[0];
|
||||
try {
|
||||
$out = StemmerFactory::create($language)->stem($word);
|
||||
} catch (NotFoundException) {
|
||||
return Event::next;
|
||||
}
|
||||
return Event::stop;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user