nadar / stemming
按语言进行词干提取
1.1.4
2023-01-11 15:38 UTC
Requires (Dev)
- luyadev/luya-testsuite: ^2.0
README
本仓库的主要目的是统一基于不同语言的词干提取组件。
安装
此包通过packagist服务分发,供composer使用。为了使用此包,必须安装composer。
composer require nadar/stemming
使用方法
使用所需语言的词干提取器
<?php include 'vendor/autoload.php'; $stemmed = \Nadar\Stemming\Stemm::stem('drinking', 'en'); echo $stemmed; // output: "drink"
如果找不到提供的语言,将返回原始单词。
您还可以提取整个短语的词干
echo \Nadar\Stemming\Stemm::stemPhrase('I am playing drums', 'en');
忽略
某些单词位于忽略列表中,对所有语言有效,请参阅Stemm::$ignore。您可以使用Stemm::$ignore = ['foo', 'bar']
调整此列表。
使用的库
- 德语词干提取: https://github.com/arisro/german-stemmer (版权所有 (c) 2013 Aris Buzachis (buzachis.aris@gmail.com))
- 英语词干提取: https://tartarus.org/martin/PorterStemmer/php.txt (版权所有 (c) 2005 Richard Heyes (http://www.phpguru.org/))
测试和PR
为了测试库,请运行
./vendor/bin/phpunit tests
为了运行代码并修复psr2,请运行
./vendor/bin/php-cs-fixer fix src/