wamania/php-stemmer

Native PHP Stemmer

Installs: 1 879 491

Dependents: 26

Suggesters: 1

Security: 0

Stars: 122

Watchers: 14

Forks: 29

Open Issues: 2

v3.0.1 2023-05-11 10:50 UTC

This package is auto-updated.

Last update: 2024-04-04 15:42:59 UTC


README

PHP native implementation of Snowball stemmer https://snowballstem.org/

Accept only UTF-8

Languages

Available :

  • Catalan (by Orestes Sanchez Benavente orestes@estotienearreglo.es)
  • Danish
  • Dutch
  • English
  • Finnish (by Mikko Saari)
  • French
  • German
  • Italian
  • Norwegian
  • Portuguese
  • Romanian
  • Russian
  • Spanish
  • Swedish

Installation

For PHP5, use 1.3

composer require wamania/php-stemmer "^1.3"

For PHP7 use 2.x (branch 2.x is backward compatible with 1.x)

composer require wamania/php-stemmer "^2.0"

For PHP^7.3 and PHP^8.0 use 3.x (backward compatible, but phpunit^9 don't work with php < 7.3)

composer require wamania/php-stemmer "^3.0"

Usage

For 2.x, you should use the factory

use Wamania\Snowball\StemmerFactory;

// use ISO_639 (2 or 3 letters) or language name in english
$stemmer = StemmerFactory::create('fr');
$stemmer = StemmerFactory::create ('spanish');

// then 
$stem = $stemmer->stem('automóvil');

Or the manager

use Wamania\Snowball\StemmerManager;

$manager = new StemmerManager();
$stem = $manager->stem('automóvil', 'es');

In 1.3, you must instantiate manually

use Wamania\Snowball\French;

$stemmer = new French();
$stem = $stemmer->stem('anticonstitutionnellement');