return;
}
- $songs = map(function ($song) use ($arguments) {
+ $songs = filter(notEmpty)(map(function ($song) use ($arguments) {
$justTitle = explode('/', $song)[1];
- similar_text(strtolower($arguments), strtolower($song), $perc);
- return ['title' => $song, 'similarity' => $perc];
- })(unserialize(file_get_contents(__DIR__ . '/hashmap.txt')));
+ similar_text(strtolower($arguments), strtolower($justTitle), $perc);
+
+ if (!empty(array_intersect(explode(' ', $arguments), explode(' ', $justTitle)))) {
+ $perc += 50;
+ }
+ return $perc > 50 ? ['title' => $song, 'similarity' => $perc ] : [];
+ })(unserialize(file_get_contents(__DIR__ . '/hashmap.txt'))));
$top5 = ∘(unlines, aaray_column('title'), aaray_slice(0)(5), 'array_reverse', 'array_values', ssort(∘(∘f(field('similarity')), ⬄, field('similarity'))));
$this->replyWithMessage(
$faveMap = ∘(map(∘(flip(concat)("'s Faves"), 'ucwords', field(0), delemit('.'), 'basename')), foldMap(☐(field(1))(field(0))), foldMap(id))(zzipWith(∘(map, aaray_merge))($names)($hashes));
$newFaves = zzipWith(∘(concat, flip(concat)(" in "), field(1), delemit('/'), flip(field)($songHashMap)))(array_keys($faveMap))(array_values($faveMap));
- $thing = map(function ($fave) use ($arguments) {
+ $thing = filter(notEmpty)(map(function ($fave) use ($arguments) {
$justTitle = join(' ', array_slice(explode(' ', $fave), 0 , -2));
similar_text(strtolower($arguments), strtolower($justTitle), $perc);
+
+ if (!empty(array_intersect(explode(' ', $arguments), explode(' ', $justTitle)))) {
+ $perc += 50;
+ }
return ['title' => $fave, 'similarity' => $perc];
- })($newFaves);
+ })($newFaves));
$top5 = ∘(unlines, aaray_column('title'), aaray_slice(0)(5), 'array_reverse', 'array_values', ssort(∘(∘f(field('similarity')), ⬄, field('similarity'))));
$this->replyWithMessage(