From 26b95fae96861e2b87b6e244da7893133a5e9e56 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Wed, 8 Dec 2021 21:50:26 +0000 Subject: [PATCH] [PLUGIN][StemWord] Remove the country part from the code. Ignore if no stemmer is found for the given language --- plugins/StemWord/StemWord.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/StemWord/StemWord.php b/plugins/StemWord/StemWord.php index b7a2c04565..b1c0d88fd5 100644 --- a/plugins/StemWord/StemWord.php +++ b/plugins/StemWord/StemWord.php @@ -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; } }