timostamm / text-scoring
dev-master
2017-10-03 16:11 UTC
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ~6.3
This package is auto-updated.
Last update: 2024-09-05 18:29:11 UTC
README
该库根据加权关键词对输入文本进行评分。
它可以用来将一组兴趣与一系列关键词相关联,并评估给定文本的相关性。
示例
// We setup our keywords. // If "VW" is present in the text, add 10 points to the score. // If "Stammmarke" is present in the text, add 5 points to the score. $criteria = [ new TextScoreKeyword('VW', 10), new TextScoreKeyword('Stammmarke', 5) ]; // This is our example text. It contains both keywords, // so it should score 15 points. $txt = 'Volkswagen (Abkürzung VW) ist die Stammmarke der Volkswagen AG.'; $scorer = new TextScorer($criteria); $score = $scorer->score($txt); print $score; // => 15