timostamm / text-scoring
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Language:Puppet
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ~6.3
This package is auto-updated.
Last update: 2024-12-05 19:03:21 UTC
README
This Library scores an input text based on weighted keywords.
It can be used to associate a selection of interests with a bunch of keywords and evaluate the relevance of a given text.
Example
// 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