From efed5c37150486a3fd595f8d22ce23025bb86357 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Tue, 7 May 2019 12:51:21 -0700 Subject: [PATCH] Spinach: bugfix ja_convert.pl --- misc/spinach/ja_convert.pl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/misc/spinach/ja_convert.pl b/misc/spinach/ja_convert.pl index d91691a9..df070c3e 100755 --- a/misc/spinach/ja_convert.pl +++ b/misc/spinach/ja_convert.pl @@ -12,10 +12,9 @@ my $questions = { questions => [] }; my $debug = 0; my $kill_id = 9999999; -#my $kill_id = 10; +#$kill_id = 10; my @files = glob '*game*.html'; -#my @files = glob '*game-1022.html'; my $id = 0; @@ -131,12 +130,14 @@ foreach my $file (@files) { $question =~ s/^\s+|\s+$//g; $answer =~ s/^\s+|\s+$//g; - if ($clue_value =~ m/\$(\d+,?\d+)/) { + if ($clue_value =~ m/(\d+,?\d+)$/) { $clue_value = $1; - } elsif ($clue_value =~ m/^(\d+)$/) { + } elsif ($clue_value =~ m/(\d+)$/) { $clue_value = $1; } + $clue_value =~ s/,//g; + if (not $clue_value) { print "Bad clue value.\n"; die; @@ -151,6 +152,10 @@ foreach my $file (@files) { print "Has alternates: [$answer] ", join (', ', @alternates), "\n"; } + # "numify" values for JSON + $id += 0; + $clue_value += 0; + my $new_question = { alternativeSpellings => \@alternates, suggestions => [],