From a64c488e21829182582bb43b2c9e399fe6ff2149 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Wed, 24 Nov 2021 15:53:23 +0000 Subject: [PATCH] [PLUGINS] Add StemWord plugin, which stems words, given a language. Currently used for tags --- plugins/StemWord/StemWord.php | 37 ++++++++++++++++++++++++++++++++++ plugins/StemWord/composer.json | 5 +++++ 2 files changed, 42 insertions(+) create mode 100644 plugins/StemWord/StemWord.php create mode 100644 plugins/StemWord/composer.json diff --git a/plugins/StemWord/StemWord.php b/plugins/StemWord/StemWord.php new file mode 100644 index 0000000000..899e8ac529 --- /dev/null +++ b/plugins/StemWord/StemWord.php @@ -0,0 +1,37 @@ +. + +// }}} + +namespace Plugin\StemWord; + +use App\Core\Event; +use App\Core\Modules\Plugin; +use Wamania\Snowball\StemmerFactory; + +class StemWord extends Plugin +{ + public function onStemWord(string $language, string $word, string &$out) + { + $out = StemmerFactory::create($language)->stem($word); + return Event::stop; + } +} diff --git a/plugins/StemWord/composer.json b/plugins/StemWord/composer.json new file mode 100644 index 0000000000..4c472d8bdf --- /dev/null +++ b/plugins/StemWord/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "wamania/php-stemmer": "^3.0" + } +}