-
-
Save castaway/708162 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use warnings; | |
use strict; | |
use Data::ICal; | |
use Text::LevenshteinXS 'distance'; | |
my $act_schedule = Data::ICal->new(filename => 'timetable.ics') | |
or die "Can't parse timetable.ics: $!"; | |
my $target = "Things I learned from users"; | |
my $mangled_target = uc $target; | |
$mangled_target =~ s/\W//g; | |
my @possibles; | |
for my $entry (@{$act_schedule->entries}) { | |
my $title = $entry->property('SUMMARY')->[0]->decoded_value; | |
my $description = $entry->property('DESCRIPTION')->[0]->decoded_value; | |
my $eid = $entry->property('URL')->[0]->decoded_value; | |
$eid =~ s!/$!!; | |
$eid =~ m!.*/(.*?)$! or die "Couldn't find last component in $eid"; | |
$eid = $1; | |
my $mangled_title = uc $title; | |
$mangled_title =~ s/\W//g; | |
my $score = (length($mangled_title) - distance($mangled_title, $mangled_target))/length($mangled_title); | |
# print "Score for $mangled_title vs $mangled_target = $score\n"; | |
push @possibles, { | |
score => $score, | |
title => $title, | |
description => $description, | |
event_id => $eid | |
}; | |
} | |
@possibles = sort {$b->{score} <=> $a->{score}} @possibles; | |
print "ye2010/$target/ http://conferences.yapceurope.org/ye2010/talk/$possibles[0]{event_id}\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment