mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-24 11:42:35 +01:00
C Jeopardy: Show correct typographical case for answers
This commit is contained in:
parent
d49700d1e1
commit
88dc009ae7
@ -13,7 +13,7 @@ use warnings;
|
||||
# These are set automatically by the build/commit script
|
||||
use constant {
|
||||
BUILD_NAME => "PBot",
|
||||
BUILD_REVISION => 755,
|
||||
BUILD_REVISION => 756,
|
||||
BUILD_DATE => "2014-07-29",
|
||||
};
|
||||
|
||||
|
@ -37,13 +37,13 @@ open my $fh, "<", "$CJEOPARDY_DATA-$channel" or print "There is no open C Jeopar
|
||||
@data = <$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) {
|
||||
chomp $answer;
|
||||
$answer =~ s/\\\|/|/g;
|
||||
|
||||
my $distance = fastdistance($text, $answer);
|
||||
my $distance = fastdistance($text, lc $answer);
|
||||
my $length = (length($text) > length($answer)) ? length $text : length $answer;
|
||||
|
||||
if ($distance / $length < 0.15) {
|
||||
@ -54,7 +54,7 @@ foreach my $answer (@valid_answers) {
|
||||
$correctness = "close enough to '$answer'. You are correct!"
|
||||
}
|
||||
|
||||
print "'$text' is $correctness\n";
|
||||
print "'$answer' is $correctness\n";
|
||||
unlink "$CJEOPARDY_DATA-$channel";
|
||||
unlink "$CJEOPARDY_HINT-$channel";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user