Text::TFIdf
Given a set of documents, generates TF-IDF Vectors for them.
Installation
panda install Text::TFIdf
Usage
use Text::TFIdf;
my %stop-words;
my $doc-store = TFIdf.new(:trim(True), :stop-list(%stop-words));
$doc-store.add('perl is cool');
$doc-store.add('i like node');
$doc-store.add('java is okay');
$doc-store.add('perl and node are interesting meh about java');
sub results($id, $score) {
say $id ~ " got " ~ $score;
}
$doc-store.tfids('node perl java', &results);
Output:
0 got 0.858454714967854
1 got 0.858454714967854
2 got 0.858454714967854
3 got 2.17296349726238
Acknowledgements