3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-12-25 04:02:37 +01:00

C Jeopardy: Show correct typographical case for answers

This commit is contained in:
Pragmatic Software 2014-07-29 19:00:06 +00:00
parent d49700d1e1
commit 88dc009ae7
2 changed files with 4 additions and 4 deletions

View File

@ -13,7 +13,7 @@ use warnings;
# These are set automatically by the build/commit script # These are set automatically by the build/commit script
use constant { use constant {
BUILD_NAME => "PBot", BUILD_NAME => "PBot",
BUILD_REVISION => 755, BUILD_REVISION => 756,
BUILD_DATE => "2014-07-29", BUILD_DATE => "2014-07-29",
}; };

View File

@ -37,13 +37,13 @@ open my $fh, "<", "$CJEOPARDY_DATA-$channel" or print "There is no open C Jeopar
@data = <$fh>; @data = <$fh>;
close $fh; close $fh;
my @valid_answers = map { lc decode $_ } split /\|/, encode $data[1]; my @valid_answers = map { decode $_ } split /\|/, encode $data[1];
foreach my $answer (@valid_answers) { foreach my $answer (@valid_answers) {
chomp $answer; chomp $answer;
$answer =~ s/\\\|/|/g; $answer =~ s/\\\|/|/g;
my $distance = fastdistance($text, $answer); my $distance = fastdistance($text, lc $answer);
my $length = (length($text) > length($answer)) ? length $text : length $answer; my $length = (length($text) > length($answer)) ? length $text : length $answer;
if ($distance / $length < 0.15) { if ($distance / $length < 0.15) {
@ -54,7 +54,7 @@ foreach my $answer (@valid_answers) {
$correctness = "close enough to '$answer'. You are correct!" $correctness = "close enough to '$answer'. You are correct!"
} }
print "'$text' is $correctness\n"; print "'$answer' is $correctness\n";
unlink "$CJEOPARDY_DATA-$channel"; unlink "$CJEOPARDY_DATA-$channel";
unlink "$CJEOPARDY_HINT-$channel"; unlink "$CJEOPARDY_HINT-$channel";