You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
414 B

#!/usr/bin/env perl6
sub MAIN ($term) {
my @data = dir("./data").hyper.map({.slurp});
my @counts = @data.hyper.map({
.match(/ <|w><$term><|w> /, :g)
.Int
});
my $document-frequency = [+] @counts.hyper.map({.Bool});
my @scores = @counts.hyper.map({
$_ * (1 / $document-frequency)
});
say 'no match' and exit 2 unless $document-frequency;
say (@data Z @scores)
.sort({.tail})
.tail
.head;
}