blib/lib/Decaptcha/TextCaptcha.pm

filter: Statementstmt 99.2% 124 / 125 Branchbran 97.4% 76 / 78 Conditioncond 95.5% 172 / 180 MC/DCmcdc 90.4% 76 / 84 Subroutinesub 100% 20 / 20 Podpod 100% 1 / 1 totaltotal 96.1% 469 / 488 CC 101 SCAR 44.5
CC
101
Cov
97%
decaptcha
101.3
BEGIN
1.0
BEGIN
1.0
CRAP 85.4
↑ Summary
1 package Decaptcha::TextCaptcha;
2  
3 2 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Lingua::EN::Words2Nums;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use List::Util qw(first max min);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 our $VERSION = '0.02';
12 2 $VERSION = eval $VERSION;
13  
14 2 our @EXPORT = qw(decaptcha);
15  
16 2 my %body_part = map { $_ => 1 } qw(
17 ankle arm brain chest chin ear elbow eye face finger foot hair hand head
18 heart knee leg nose stomach thumb toe tongue tooth waist
19 );
20 2 my %head_part = map { $_ => 1 } qw(
21 brain chin ear eye face hair head mouth nose tooth
22 );
23 2 my %multiple_part = map { $_ => 1 } qw(
24 ankle arm ear elbow eye finger foot hand knee leg thumb toe tooth
25 );
26 2 my %part_above_waist = map { $_ => 1 } qw(
27 arm brain chest chin ear elbow eye face finger foot hair hand head heart
28 mouth nose stomach thumb tongue tooth
29 );
30 2 my %part_below_waist = map {$_ => 1} qw( ankle foot knee leg toe );
31  
32 2 my %colors = map { $_ => 1 } qw(
33 black blue brown green pink purple red white yellow
34 );
35  
36 2 my @days = qw(sunday monday tuesday wednesday thursday friday saturday);
37 2 my %days; @days{@days} = (0 .. @days);
38 2 my %weekend = map { $_ => 1 } @days[0,6];
39  
40  
41 120 ▶sub decaptcha {
Subroutine decaptcha: called CC=101 SCAR=46.2
Pod documented
42 120 ▶ my $q = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $q = shift() or return 118 2 120
43 118 my $lq = lc $q;
44  
45 # Words and letters
46 118 ▶ if ($lq eq 'which word in this sentence is all in capitals?') {
Branch: 1 branch
BranchTrueFalseTotal
if ($lq eq "which word in this sentence is all in capitals?") 2 116 118
47 2 ▶ my $word = first { ! tr/a-z// } split /\W+/, $q;
Subroutine __ANON__: called CC=1 SCAR=0.0
48 2 ▶ return $word ? lc $word : undef;
Branch: 1 branch
BranchTrueFalseTotal
$word ? : 1 1 2
49 }
50 116 ▶ if ($lq =~ /^(?:the word )?"(.*?)" has how many letters\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^(?:the word )?"(.*?)" has how many letters\?$/ or $lq =~ /^how many letters in (?:the word )?"(.*?)"\?$/) 2 114 116
Condition100%3/3
$lq =~ /^(?:the word )?"(.*?)" has how many letters\?$/ or $lq =~ /^how many letters in (?:the word )?"(.*?)"\?$/
l!l&&r!l&&!r
11114
MC/DC100%2/2
$lq =~ /^(?:the word )?"(.*?)" has how many letters\?$/ or $lq =~ /^how many letters in (?:the word )?"(.*?)"\?$/
$lq =~ /^(?:the word )?"(.*?)" has how many letters\?$/ $lq =~ /^how many letters in (?:the word )?"(.*?)"\?$/
Truth table100%3/3
A or B
A= $lq =~ /^(?:the word )?"(.*?)" has how many letters\?$/B= $lq =~ /^how many letters in (?:the word )?"(.*?)"\?$/
ABresult
1X1
011
000
51 or $lq =~ /^how many letters in (?:the word )?"(.*?)"\?$/
52 ) {
53 2 return length $1;
54 }
55 114 ▶ if ($q =~ /^The word in capitals from (.*?) is\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($q =~ /^The word in capitals from (.*?) is\?$/ or $q =~ /^Which word is all in capitals: (.*?)\?$/ or $q =~ /^Which of (.*?) is in capitals\?$/) 4 110 114
Condition100%6/6
$q =~ /^The word in capitals from (.*?) is\?$/ or $q =~ /^Which word is all in capitals: (.*?)\?$/ or $q =~ /^Which of (.*?) is in capitals\?$/
l!l&&r!l&&!r
31110
$q =~ /^The word in capitals from (.*?) is\?$/ or $q =~ /^Which word is all in capitals: (.*?)\?$/
l!l&&r!l&&!r
21111
MC/DC100%3/3
$q =~ /^The word in capitals from (.*?) is\?$/ or $q =~ /^Which word is all in capitals: (.*?)\?$/ or $q =~ /^Which of (.*?) is in capitals\?$/
$q =~ /^The word in capitals from (.*?) is\?$/ $q =~ /^Which word is all in capitals: (.*?)\?$/ $q =~ /^Which of (.*?) is in capitals\?$/
Truth table100%4/4
A or B or C
A= $q =~ /^The word in capitals from (.*?) is\?$/B= $q =~ /^Which word is all in capitals: (.*?)\?$/C= $q =~ /^Which of (.*?) is in capitals\?$/
ABCresult
1XX1
01X1
0011
0000
56 or $q =~ /^Which word is all in capitals: (.*?)\?$/
57 or $q =~ /^Which of (.*?) is in capitals\?$/
58 ) {
59 4 ▶ my $word = first { ! tr/a-z// } split /(?:,\s*| or )/, $1;
Subroutine __ANON__: called CC=1 SCAR=0.0
60 4 ▶ return $word ? lc $word : undef;
Branch: 1 branch
BranchTrueFalseTotal
$word ? : 3 1 4
61 }
62 110 ▶ if ($lq =~ /^which word starts with "(?<c>.)" from the list: (?<l>.*?)\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^which word starts with "(?<c>.)" from the list: (?<l>.*?)\?$/ or $lq =~ /which word from list "(?<l>.*?)" has "(?<c>.)" as a first letter\?$/ or $lq =~ /^what word from "(?<l>.*?)" begins with "(?<c>.)"\?$/ or $lq =~ /^(?<l>.*?): the word starting with "(?<c>.)" is\?$/) 6 104 110
Condition100%9/9
$lq =~ /^which word starts with "(?<c>.)" from the list: (?<l>.*?)\?$/ or $lq =~ /which word from list "(?<l>.*?)" has "(?<c>.)" as a first letter\?$/ or $lq =~ /^what word from "(?<l>.*?)" begins with "(?<c>.)"\?$/ or $lq =~ /^(?<l>.*?): the word starting with "(?<c>.)" is\?$/
l!l&&r!l&&!r
51104
$lq =~ /^which word starts with "(?<c>.)" from the list: (?<l>.*?)\?$/ or $lq =~ /which word from list "(?<l>.*?)" has "(?<c>.)" as a first letter\?$/ or $lq =~ /^what word from "(?<l>.*?)" begins with "(?<c>.)"\?$/
l!l&&r!l&&!r
32105
$lq =~ /^which word starts with "(?<c>.)" from the list: (?<l>.*?)\?$/ or $lq =~ /which word from list "(?<l>.*?)" has "(?<c>.)" as a first letter\?$/
l!l&&r!l&&!r
21107
MC/DC100%4/4
$lq =~ /^which word starts with "(?<c>.)" from the list: (?<l>.*?)\?$/ or $lq =~ /which word from list "(?<l>.*?)" has "(?<c>.)" as a first letter\?$/ or $lq =~ /^what word from "(?<l>.*?)" begins with "(?<c>.)"\?$/ or $lq =~ /^(?<l>.*?): the word starting with "(?<c>.)" is\?$/
$lq =~ /^which word starts with "(?<c>.)" from the list: (?<l>.*?)\?$/ $lq =~ /which word from list "(?<l>.*?)" has "(?<c>.)" as a first letter\?$/ $lq =~ /^what word from "(?<l>.*?)" begins with "(?<c>.)"\?$/ $lq =~ /^(?<l>.*?): the word starting with "(?<c>.)" is\?$/
Truth table100%5/5
A or B or C or D
A= $lq =~ /^which word starts with "(?<c>.)" from the list: (?<l>.*?)\?$/B= $lq =~ /which word from list "(?<l>.*?)" has "(?<c>.)" as a first letter\?$/C= $lq =~ /^what word from "(?<l>.*?)" begins with "(?<c>.)"\?$/D= $lq =~ /^(?<l>.*?): the word starting with "(?<c>.)" is\?$/
ABCDresult
1XXX1
01XX1
001X1
00011
00000
63 or $lq =~ /which word from list "(?<l>.*?)" has "(?<c>.)" as a first letter\?$/
64 or $lq =~ /^what word from "(?<l>.*?)" begins with "(?<c>.)"\?$/
65 or $lq =~ /^(?<l>.*?): the word starting with "(?<c>.)" is\?$/
66 ) {
67 6 ▶ return first { $+{c} eq substr $_, 0, 1 } split /,\s*/, $+{l};
Subroutine __ANON__: called CC=1 SCAR=0.0
68 }
69 104 ▶ if ($lq =~ /^which word contains "(?<c>[a-z])" from the list: (?<l>.*?)\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^which word contains "(?<c>[a-z])" from the list: (?<l>.*?)\?$/ or $lq =~ /^(?<l>.*?): the word containing the letter "(?<c>[a-z])" is\?$/ or $lq =~ /^what word from "(?<l>.*?)" contains the letter "(?<c>[a-z])"\?$/ or $lq =~ /^which word from list "(?<l>.*?)" contains the letter "(?<c>[a-z])"\?$/) 5 99 104
Condition100%9/9
$lq =~ /^which word contains "(?<c>[a-z])" from the list: (?<l>.*?)\?$/ or $lq =~ /^(?<l>.*?): the word containing the letter "(?<c>[a-z])" is\?$/ or $lq =~ /^what word from "(?<l>.*?)" contains the letter "(?<c>[a-z])"\?$/ or $lq =~ /^which word from list "(?<l>.*?)" contains the letter "(?<c>[a-z])"\?$/
l!l&&r!l&&!r
4199
$lq =~ /^which word contains "(?<c>[a-z])" from the list: (?<l>.*?)\?$/ or $lq =~ /^(?<l>.*?): the word containing the letter "(?<c>[a-z])" is\?$/ or $lq =~ /^what word from "(?<l>.*?)" contains the letter "(?<c>[a-z])"\?$/
l!l&&r!l&&!r
31100
$lq =~ /^which word contains "(?<c>[a-z])" from the list: (?<l>.*?)\?$/ or $lq =~ /^(?<l>.*?): the word containing the letter "(?<c>[a-z])" is\?$/
l!l&&r!l&&!r
21101
MC/DC100%4/4
$lq =~ /^which word contains "(?<c>[a-z])" from the list: (?<l>.*?)\?$/ or $lq =~ /^(?<l>.*?): the word containing the letter "(?<c>[a-z])" is\?$/ or $lq =~ /^what word from "(?<l>.*?)" contains the letter "(?<c>[a-z])"\?$/ or $lq =~ /^which word from list "(?<l>.*?)" contains the letter "(?<c>[a-z])"\?$/
$lq =~ /^which word contains "(?<c>[a-z])" from the list: (?<l>.*?)\?$/ $lq =~ /^(?<l>.*?): the word containing the letter "(?<c>[a-z])" is\?$/ $lq =~ /^what word from "(?<l>.*?)" contains the letter "(?<c>[a-z])"\?$/ $lq =~ /^which word from list "(?<l>.*?)" contains the letter "(?<c>[a-z])"\?$/
Truth table100%5/5
A or B or C or D
A= $lq =~ /^which word contains "(?<c>[a-z])" from the list: (?<l>.*?)\?$/B= $lq =~ /^(?<l>.*?): the word containing the letter "(?<c>[a-z])" is\?$/C= $lq =~ /^what word from "(?<l>.*?)" contains the letter "(?<c>[a-z])"\?$/D= $lq =~ /^which word from list "(?<l>.*?)" contains the letter "(?<c>[a-z])"\?$/
ABCDresult
1XXX1
01XX1
001X1
00011
00000
70 or $lq =~ /^(?<l>.*?): the word containing the letter "(?<c>[a-z])" is\?$/
71 or $lq =~ /^what word from "(?<l>.*?)" contains the letter "(?<c>[a-z])"\?$/
72 or $lq =~ /^which word from list "(?<l>.*?)" contains the letter "(?<c>[a-z])"\?$/
73 ) {
74 5 ▶ return first { 0 <= index $_, $+{c} } split /,\s*/, $+{l};
Subroutine __ANON__: called CC=1 SCAR=0.0
75 }
76 99 ▶ return $1 if $lq =~ /^the word "(.).*?" starts with which letter\?$/
Branch: 1 branch
BranchTrueFalseTotal
if $lq =~ /^the word "(.).*?" starts with which letter\?$/ or $lq =~ /^the letter at the beginning of the word "(.).*?" is\?$/ or $lq =~ /^the word "(.).*?" has which letter at the start\?$/ or $lq =~ /^the (?:last|final) letter of word ".*?(.)" is\?$/ or $lq =~ /^the word ".*?(.)" has which letter at the end\?$/ 6 93 99
Condition100%12/12
$lq =~ /^the word "(.).*?" starts with which letter\?$/ or $lq =~ /^the letter at the beginning of the word "(.).*?" is\?$/ or $lq =~ /^the word "(.).*?" has which letter at the start\?$/ or $lq =~ /^the (?:last|final) letter of word ".*?(.)" is\?$/ or $lq =~ /^the word ".*?(.)" has which letter at the end\?$/
l!l&&r!l&&!r
5193
$lq =~ /^the word "(.).*?" starts with which letter\?$/ or $lq =~ /^the letter at the beginning of the word "(.).*?" is\?$/ or $lq =~ /^the word "(.).*?" has which letter at the start\?$/ or $lq =~ /^the (?:last|final) letter of word ".*?(.)" is\?$/
l!l&&r!l&&!r
3294
$lq =~ /^the word "(.).*?" starts with which letter\?$/ or $lq =~ /^the letter at the beginning of the word "(.).*?" is\?$/ or $lq =~ /^the word "(.).*?" has which letter at the start\?$/
l!l&&r!l&&!r
2196
$lq =~ /^the word "(.).*?" starts with which letter\?$/ or $lq =~ /^the letter at the beginning of the word "(.).*?" is\?$/
l!l&&r!l&&!r
1197
MC/DC100%5/5
$lq =~ /^the word "(.).*?" starts with which letter\?$/ or $lq =~ /^the letter at the beginning of the word "(.).*?" is\?$/ or $lq =~ /^the word "(.).*?" has which letter at the start\?$/ or $lq =~ /^the (?:last|final) letter of word ".*?(.)" is\?$/ or $lq =~ /^the word ".*?(.)" has which letter at the end\?$/
$lq =~ /^the word "(.).*?" starts with which letter\?$/ $lq =~ /^the letter at the beginning of the word "(.).*?" is\?$/ $lq =~ /^the word "(.).*?" has which letter at the start\?$/ $lq =~ /^the (?:last|final) letter of word ".*?(.)" is\?$/ $lq =~ /^the word ".*?(.)" has which letter at the end\?$/
Truth table100%6/6
A or B or C or D or E
A= $lq =~ /^the word "(.).*?" starts with which letter\?$/B= $lq =~ /^the letter at the beginning of the word "(.).*?" is\?$/C= $lq =~ /^the word "(.).*?" has which letter at the start\?$/D= $lq =~ /^the (?:last|final) letter of word ".*?(.)" is\?$/E= $lq =~ /^the word ".*?(.)" has which letter at the end\?$/
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
77 or $lq =~ /^the letter at the beginning of the word "(.).*?" is\?$/
78 or $lq =~ /^the word "(.).*?" has which letter at the start\?$/
79 or $lq =~ /^the (?:last|final) letter of word ".*?(.)" is\?$/
80 or $lq =~ /^the word ".*?(.)" has which letter at the end\?$/;
81 93 ▶ if ($lq =~ /^the (?<p>\d+)\S+ letter in (?:the word )?"(?<w>.*?)" is\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^the (?<p>\d+)\S+ letter in (?:the word )?"(?<w>.*?)" is\?$/ or $lq =~ /^the word "(?<w>.*?)" has which letter in (?<p>\d+)\S+ position\?$/) 3 90 93
Condition100%3/3
$lq =~ /^the (?<p>\d+)\S+ letter in (?:the word )?"(?<w>.*?)" is\?$/ or $lq =~ /^the word "(?<w>.*?)" has which letter in (?<p>\d+)\S+ position\?$/
l!l&&r!l&&!r
1290
MC/DC100%2/2
$lq =~ /^the (?<p>\d+)\S+ letter in (?:the word )?"(?<w>.*?)" is\?$/ or $lq =~ /^the word "(?<w>.*?)" has which letter in (?<p>\d+)\S+ position\?$/
$lq =~ /^the (?<p>\d+)\S+ letter in (?:the word )?"(?<w>.*?)" is\?$/ $lq =~ /^the word "(?<w>.*?)" has which letter in (?<p>\d+)\S+ position\?$/
Truth table100%3/3
A or B
A= $lq =~ /^the (?<p>\d+)\S+ letter in (?:the word )?"(?<w>.*?)" is\?$/B= $lq =~ /^the word "(?<w>.*?)" has which letter in (?<p>\d+)\S+ position\?$/
ABresult
1X1
011
000
82 or $lq =~ /^the word "(?<w>.*?)" has which letter in (?<p>\d+)\S+ position\?$/
83 ) {
84  
85 3 ▶ return $+{p} > length $+{w} ? undef : substr $+{w}, $+{p} - 1, 1;
Branch: 1 branch
BranchTrueFalseTotal
$+{'p'} > length $+{'w'} ? : 1 2 3
86 }
87  
88 # Days of week
89 90 ▶ if ($lq =~ /^tomorrow is (\w+)\. if this is true, what day is today\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^tomorrow is (\w+)\. if this is true, what day is today\?$/ or $lq =~ /^if tomorrow is (\w+), what day is today\?$/ or $lq =~ /^what day is today, if tomorrow is (\w+)\?$/) 4 86 90
Condition100%6/6
$lq =~ /^tomorrow is (\w+)\. if this is true, what day is today\?$/ or $lq =~ /^if tomorrow is (\w+), what day is today\?$/ or $lq =~ /^what day is today, if tomorrow is (\w+)\?$/
l!l&&r!l&&!r
3186
$lq =~ /^tomorrow is (\w+)\. if this is true, what day is today\?$/ or $lq =~ /^if tomorrow is (\w+), what day is today\?$/
l!l&&r!l&&!r
1287
MC/DC100%3/3
$lq =~ /^tomorrow is (\w+)\. if this is true, what day is today\?$/ or $lq =~ /^if tomorrow is (\w+), what day is today\?$/ or $lq =~ /^what day is today, if tomorrow is (\w+)\?$/
$lq =~ /^tomorrow is (\w+)\. if this is true, what day is today\?$/ $lq =~ /^if tomorrow is (\w+), what day is today\?$/ $lq =~ /^what day is today, if tomorrow is (\w+)\?$/
Truth table100%4/4
A or B or C
A= $lq =~ /^tomorrow is (\w+)\. if this is true, what day is today\?$/B= $lq =~ /^if tomorrow is (\w+), what day is today\?$/C= $lq =~ /^what day is today, if tomorrow is (\w+)\?$/
ABCresult
1XX1
01X1
0011
0000
90 or $lq =~ /^if tomorrow is (\w+), what day is today\?$/
91 or $lq =~ /^what day is today, if tomorrow is (\w+)\?$/
92 ) {
93 4 ▶ return exists $days{$1} ? $days[ ($days{$1} - 1) % 7 ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
exists $days{$1} ? : 3 1 4
94 }
95 86 ▶ if ($lq =~ /^yesterday was (\w+)\. if this is true, what day is today\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^yesterday was (\w+)\. if this is true, what day is today\?$/ or $lq =~ /^if yesterday was (\w+), what day is today\?$/ or $lq =~ /^what day is today, if yesterday was (\w+)\?$/) 4 82 86
Condition100%6/6
$lq =~ /^yesterday was (\w+)\. if this is true, what day is today\?$/ or $lq =~ /^if yesterday was (\w+), what day is today\?$/ or $lq =~ /^what day is today, if yesterday was (\w+)\?$/
l!l&&r!l&&!r
3182
$lq =~ /^yesterday was (\w+)\. if this is true, what day is today\?$/ or $lq =~ /^if yesterday was (\w+), what day is today\?$/
l!l&&r!l&&!r
1283
MC/DC100%3/3
$lq =~ /^yesterday was (\w+)\. if this is true, what day is today\?$/ or $lq =~ /^if yesterday was (\w+), what day is today\?$/ or $lq =~ /^what day is today, if yesterday was (\w+)\?$/
$lq =~ /^yesterday was (\w+)\. if this is true, what day is today\?$/ $lq =~ /^if yesterday was (\w+), what day is today\?$/ $lq =~ /^what day is today, if yesterday was (\w+)\?$/
Truth table100%4/4
A or B or C
A= $lq =~ /^yesterday was (\w+)\. if this is true, what day is today\?$/B= $lq =~ /^if yesterday was (\w+), what day is today\?$/C= $lq =~ /^what day is today, if yesterday was (\w+)\?$/
ABCresult
1XX1
01X1
0011
0000
96 or $lq =~ /^if yesterday was (\w+), what day is today\?$/
97 or $lq =~ /^what day is today, if yesterday was (\w+)\?$/
98 ) {
99 4 ▶ return exists $days{$1} ? $days[ ($days{$1} + 1) % 7 ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
exists $days{$1} ? : 3 1 4
100 }
101 82 ▶ if ($lq =~ /^which of these is a day of the week: (.*?)\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^which of these is a day of the week: (.*?)\?$/ or $lq =~ /^which of (.*?) is a day of the week\?$/ or $lq =~ /^which of (.*?) is the name of a day\?$/ or $lq =~ /^the day of the week in (.*?) is\?$/ or $lq =~ /^(.*?): the day of the week is\?$/) 6 76 82
Condition100%12/12
$lq =~ /^which of these is a day of the week: (.*?)\?$/ or $lq =~ /^which of (.*?) is a day of the week\?$/ or $lq =~ /^which of (.*?) is the name of a day\?$/ or $lq =~ /^the day of the week in (.*?) is\?$/ or $lq =~ /^(.*?): the day of the week is\?$/
l!l&&r!l&&!r
5176
$lq =~ /^which of these is a day of the week: (.*?)\?$/ or $lq =~ /^which of (.*?) is a day of the week\?$/ or $lq =~ /^which of (.*?) is the name of a day\?$/ or $lq =~ /^the day of the week in (.*?) is\?$/
l!l&&r!l&&!r
4177
$lq =~ /^which of these is a day of the week: (.*?)\?$/ or $lq =~ /^which of (.*?) is a day of the week\?$/ or $lq =~ /^which of (.*?) is the name of a day\?$/
l!l&&r!l&&!r
3178
$lq =~ /^which of these is a day of the week: (.*?)\?$/ or $lq =~ /^which of (.*?) is a day of the week\?$/
l!l&&r!l&&!r
2179
MC/DC100%5/5
$lq =~ /^which of these is a day of the week: (.*?)\?$/ or $lq =~ /^which of (.*?) is a day of the week\?$/ or $lq =~ /^which of (.*?) is the name of a day\?$/ or $lq =~ /^the day of the week in (.*?) is\?$/ or $lq =~ /^(.*?): the day of the week is\?$/
$lq =~ /^which of these is a day of the week: (.*?)\?$/ $lq =~ /^which of (.*?) is a day of the week\?$/ $lq =~ /^which of (.*?) is the name of a day\?$/ $lq =~ /^the day of the week in (.*?) is\?$/ $lq =~ /^(.*?): the day of the week is\?$/
Truth table100%6/6
A or B or C or D or E
A= $lq =~ /^which of these is a day of the week: (.*?)\?$/B= $lq =~ /^which of (.*?) is a day of the week\?$/C= $lq =~ /^which of (.*?) is the name of a day\?$/D= $lq =~ /^the day of the week in (.*?) is\?$/E= $lq =~ /^(.*?): the day of the week is\?$/
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
102 or $lq =~ /^which of (.*?) is a day of the week\?$/
103 or $lq =~ /^which of (.*?) is the name of a day\?$/
104 or $lq =~ /^the day of the week in (.*?) is\?$/
105 or $lq =~ /^(.*?): the day of the week is\?$/
106 ) {
107 6 ▶ return first { exists $days{$_} } split /\W+/, $1;
Subroutine __ANON__: called CC=1 SCAR=0.0
108 }
109 76 ▶ if ($lq =~ /^(.*?) is part of the weekend\?$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^(.*?) is part of the weekend\?$/) 4 72 76
110 4 ▶ return first { $weekend{$_} } split /\W+/, $1;
Subroutine __ANON__: called CC=1 SCAR=0.0
111 }
112  
113 # Names
114 72 ▶ return $1 if $lq =~ /^(\w+)'s? name is\?$/
Branch: 1 branch
BranchTrueFalseTotal
if $lq =~ /^(\w+)'s? name is\?$/ or $lq =~ /^what is (\w+)'s? name\?$/ or $lq =~ /^the name of (\w+) is\?$/ or $lq =~ /^if a person is called (\w+), what is their name\?$/ 4 68 72
Condition100%9/9
$lq =~ /^(\w+)'s? name is\?$/ or $lq =~ /^what is (\w+)'s? name\?$/ or $lq =~ /^the name of (\w+) is\?$/ or $lq =~ /^if a person is called (\w+), what is their name\?$/
l!l&&r!l&&!r
3168
$lq =~ /^(\w+)'s? name is\?$/ or $lq =~ /^what is (\w+)'s? name\?$/ or $lq =~ /^the name of (\w+) is\?$/
l!l&&r!l&&!r
2169
$lq =~ /^(\w+)'s? name is\?$/ or $lq =~ /^what is (\w+)'s? name\?$/
l!l&&r!l&&!r
1170
MC/DC100%4/4
$lq =~ /^(\w+)'s? name is\?$/ or $lq =~ /^what is (\w+)'s? name\?$/ or $lq =~ /^the name of (\w+) is\?$/ or $lq =~ /^if a person is called (\w+), what is their name\?$/
$lq =~ /^(\w+)'s? name is\?$/ $lq =~ /^what is (\w+)'s? name\?$/ $lq =~ /^the name of (\w+) is\?$/ $lq =~ /^if a person is called (\w+), what is their name\?$/
Truth table100%5/5
A or B or C or D
A= $lq =~ /^(\w+)'s? name is\?$/B= $lq =~ /^what is (\w+)'s? name\?$/C= $lq =~ /^the name of (\w+) is\?$/D= $lq =~ /^if a person is called (\w+), what is their name\?$/
ABCDresult
1XXX1
01XX1
001X1
00011
00000
115 or $lq =~ /^what is (\w+)'s? name\?$/
116 or $lq =~ /^the name of (\w+) is\?$/
117 or $lq =~ /^if a person is called (\w+), what is their name\?$/;
118 68 ▶ if ($q =~ /^The person's firstname in (.*?) is\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($q =~ /^The person's firstname in (.*?) is\?$/ or $q =~ /^Which in this list is the name of a person: (.*?)\?$/ or $q =~ /^(.*?): the person's name is\?$/ or $q =~ /^Which of (.*?) is the name of a person\?$/ or $q =~ /^Which of (.*?) is a person's name\?$/) 6 62 68
Condition91%11/12
$q =~ /^The person's firstname in (.*?) is\?$/ or $q =~ /^Which in this list is the name of a person: (.*?)\?$/ or $q =~ /^(.*?): the person's name is\?$/ or $q =~ /^Which of (.*?) is the name of a person\?$/ or $q =~ /^Which of (.*?) is a person's name\?$/
l!l&&r!l&&!r
5162
$q =~ /^The person's firstname in (.*?) is\?$/ or $q =~ /^Which in this list is the name of a person: (.*?)\?$/ or $q =~ /^(.*?): the person's name is\?$/ or $q =~ /^Which of (.*?) is the name of a person\?$/
l!l&&r!l&&!r
5063
$q =~ /^The person's firstname in (.*?) is\?$/ or $q =~ /^Which in this list is the name of a person: (.*?)\?$/ or $q =~ /^(.*?): the person's name is\?$/
l!l&&r!l&&!r
4163
$q =~ /^The person's firstname in (.*?) is\?$/ or $q =~ /^Which in this list is the name of a person: (.*?)\?$/
l!l&&r!l&&!r
2264
MC/DC80%4/5
$q =~ /^The person's firstname in (.*?) is\?$/ or $q =~ /^Which in this list is the name of a person: (.*?)\?$/ or $q =~ /^(.*?): the person's name is\?$/ or $q =~ /^Which of (.*?) is the name of a person\?$/ or $q =~ /^Which of (.*?) is a person's name\?$/
$q =~ /^The person's firstname in (.*?) is\?$/ $q =~ /^Which in this list is the name of a person: (.*?)\?$/ $q =~ /^(.*?): the person's name is\?$/ $q =~ /^Which of (.*?) is the name of a person\?$/ $q =~ /^Which of (.*?) is a person's name\?$/
Truth table83%5/6
A or B or C or D or E
A= $q =~ /^The person's firstname in (.*?) is\?$/B= $q =~ /^Which in this list is the name of a person: (.*?)\?$/C= $q =~ /^(.*?): the person's name is\?$/D= $q =~ /^Which of (.*?) is the name of a person\?$/E= $q =~ /^Which of (.*?) is a person's name\?$/
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
119 or $q =~ /^Which in this list is the name of a person: (.*?)\?$/
120 or $q =~ /^(.*?): the person's name is\?$/
121 or $q =~ /^Which of (.*?) is the name of a person\?$/
122 or $q =~ /^Which of (.*?) is a person's name\?$/
123 ) {
124 6 ▶ my $name = first { /^[A-Z][a-z]+$/ } reverse split /\W+/, $1;
Subroutine __ANON__: called CC=1 SCAR=0.0
125 6 ▶ return $name ? lc $name : undef;
Branch: 1 branch
BranchTrueFalseTotal
$name ? : 5 1 6
126 }
127  
128 # Colors
129 62 ▶ return $1 if $lq =~ /^the colour of a (\w+) \S+ is\?$/
Branch: 1 branch
BranchTrueFalseTotal
if $lq =~ /^the colour of a (\w+) \S+ is\?$/ or $lq =~ /^the (\w+) \S+ is what colour\?$/ or $lq =~ /^if the \S+ is (\w+), what colour is it\?$/ 3 59 62
Condition100%6/6
$lq =~ /^the colour of a (\w+) \S+ is\?$/ or $lq =~ /^the (\w+) \S+ is what colour\?$/ or $lq =~ /^if the \S+ is (\w+), what colour is it\?$/
l!l&&r!l&&!r
2159
$lq =~ /^the colour of a (\w+) \S+ is\?$/ or $lq =~ /^the (\w+) \S+ is what colour\?$/
l!l&&r!l&&!r
1160
MC/DC100%3/3
$lq =~ /^the colour of a (\w+) \S+ is\?$/ or $lq =~ /^the (\w+) \S+ is what colour\?$/ or $lq =~ /^if the \S+ is (\w+), what colour is it\?$/
$lq =~ /^the colour of a (\w+) \S+ is\?$/ $lq =~ /^the (\w+) \S+ is what colour\?$/ $lq =~ /^if the \S+ is (\w+), what colour is it\?$/
Truth table100%4/4
A or B or C
A= $lq =~ /^the colour of a (\w+) \S+ is\?$/B= $lq =~ /^the (\w+) \S+ is what colour\?$/C= $lq =~ /^if the \S+ is (\w+), what colour is it\?$/
ABCresult
1XX1
01X1
0011
0000
130 or $lq =~ /^the (\w+) \S+ is what colour\?$/
131 or $lq =~ /^if the \S+ is (\w+), what colour is it\?$/;
132 59 ▶ if ($lq =~ /^how many colours in the list (.*?)\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^how many colours in the list (.*?)\?$/ or $lq =~ /^the list (.*?) contains how many colours\?$/ or $lq =~ /^(.*?): how many colours in the list\?$/) 4 55 59
Condition100%6/6
$lq =~ /^how many colours in the list (.*?)\?$/ or $lq =~ /^the list (.*?) contains how many colours\?$/ or $lq =~ /^(.*?): how many colours in the list\?$/
l!l&&r!l&&!r
3155
$lq =~ /^how many colours in the list (.*?)\?$/ or $lq =~ /^the list (.*?) contains how many colours\?$/
l!l&&r!l&&!r
2156
MC/DC100%3/3
$lq =~ /^how many colours in the list (.*?)\?$/ or $lq =~ /^the list (.*?) contains how many colours\?$/ or $lq =~ /^(.*?): how many colours in the list\?$/
$lq =~ /^how many colours in the list (.*?)\?$/ $lq =~ /^the list (.*?) contains how many colours\?$/ $lq =~ /^(.*?): how many colours in the list\?$/
Truth table100%4/4
A or B or C
A= $lq =~ /^how many colours in the list (.*?)\?$/B= $lq =~ /^the list (.*?) contains how many colours\?$/C= $lq =~ /^(.*?): how many colours in the list\?$/
ABCresult
1XX1
01X1
0011
0000
133 or $lq =~ /^the list (.*?) contains how many colours\?$/
134 or $lq =~ /^(.*?): how many colours in the list\?$/
135 ) {
136 4 return 0 + grep { $colors{$_} } split /\W+/, $1;
137 }
138 55 ▶ if ($lq =~ /^which of these is a colour: (.*?)\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^which of these is a colour: (.*?)\?$/ or $lq =~ /^which of (.*?) is a colour\?$/ or $lq =~ /^(.*?): the colour is\?$/ or $lq =~ /^the colour in the list (.*?) is\?$/) 5 50 55
Condition100%9/9
$lq =~ /^which of these is a colour: (.*?)\?$/ or $lq =~ /^which of (.*?) is a colour\?$/ or $lq =~ /^(.*?): the colour is\?$/ or $lq =~ /^the colour in the list (.*?) is\?$/
l!l&&r!l&&!r
4150
$lq =~ /^which of these is a colour: (.*?)\?$/ or $lq =~ /^which of (.*?) is a colour\?$/ or $lq =~ /^(.*?): the colour is\?$/
l!l&&r!l&&!r
3151
$lq =~ /^which of these is a colour: (.*?)\?$/ or $lq =~ /^which of (.*?) is a colour\?$/
l!l&&r!l&&!r
2152
MC/DC100%4/4
$lq =~ /^which of these is a colour: (.*?)\?$/ or $lq =~ /^which of (.*?) is a colour\?$/ or $lq =~ /^(.*?): the colour is\?$/ or $lq =~ /^the colour in the list (.*?) is\?$/
$lq =~ /^which of these is a colour: (.*?)\?$/ $lq =~ /^which of (.*?) is a colour\?$/ $lq =~ /^(.*?): the colour is\?$/ $lq =~ /^the colour in the list (.*?) is\?$/
Truth table100%5/5
A or B or C or D
A= $lq =~ /^which of these is a colour: (.*?)\?$/B= $lq =~ /^which of (.*?) is a colour\?$/C= $lq =~ /^(.*?): the colour is\?$/D= $lq =~ /^the colour in the list (.*?) is\?$/
ABCDresult
1XXX1
01XX1
001X1
00011
00000
139 or $lq =~ /^which of (.*?) is a colour\?$/
140 or $lq =~ /^(.*?): the colour is\?$/
141 or $lq =~ /^the colour in the list (.*?) is\?$/
142 ) {
143 5 ▶ return first { $colors{$_} } split /\W+/, $1;
Subroutine __ANON__: called CC=1 SCAR=0.0
144 }
145 50 ▶ if ($lq =~ /^what is the (?<p>\d+)\S+ colour in the list (?<l>.*?)\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^what is the (?<p>\d+)\S+ colour in the list (?<l>.*?)\?$/ or $lq =~ /^the (?<p>\d+)\S+ colour in (?<l>.*?) is\?$/ or $lq =~ /^(?<l>.*?): the (?<p>\d+)\S+ colour is\?$/) 4 46 50
Condition83%5/6
$lq =~ /^what is the (?<p>\d+)\S+ colour in the list (?<l>.*?)\?$/ or $lq =~ /^the (?<p>\d+)\S+ colour in (?<l>.*?) is\?$/ or $lq =~ /^(?<l>.*?): the (?<p>\d+)\S+ colour is\?$/
l!l&&r!l&&!r
3146
$lq =~ /^what is the (?<p>\d+)\S+ colour in the list (?<l>.*?)\?$/ or $lq =~ /^the (?<p>\d+)\S+ colour in (?<l>.*?) is\?$/
l!l&&r!l&&!r
3047
MC/DC66%2/3
$lq =~ /^what is the (?<p>\d+)\S+ colour in the list (?<l>.*?)\?$/ or $lq =~ /^the (?<p>\d+)\S+ colour in (?<l>.*?) is\?$/ or $lq =~ /^(?<l>.*?): the (?<p>\d+)\S+ colour is\?$/
$lq =~ /^what is the (?<p>\d+)\S+ colour in the list (?<l>.*?)\?$/ $lq =~ /^the (?<p>\d+)\S+ colour in (?<l>.*?) is\?$/ $lq =~ /^(?<l>.*?): the (?<p>\d+)\S+ colour is\?$/
Truth table75%3/4
A or B or C
A= $lq =~ /^what is the (?<p>\d+)\S+ colour in the list (?<l>.*?)\?$/B= $lq =~ /^the (?<p>\d+)\S+ colour in (?<l>.*?) is\?$/C= $lq =~ /^(?<l>.*?): the (?<p>\d+)\S+ colour is\?$/
ABCresult
1XX1
01X1
0011
0000
146 or $lq =~ /^the (?<p>\d+)\S+ colour in (?<l>.*?) is\?$/
147 or $lq =~ /^(?<l>.*?): the (?<p>\d+)\S+ colour is\?$/
148 ) {
149 4 return (grep { $colors{$_} } split /\W+/, $+{l})[ $+{p} - 1 ];
150 }
151  
152 # Body parts
153 46 ▶ if ($lq =~ /^the number of body parts in the list (.*?) is\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^the number of body parts in the list (.*?) is\?$/ or $lq =~ /^the list (.*?) contains how many body parts\?$/ or $lq =~ /^(.*?): how many body parts in the list\?$/) 4 42 46
Condition100%6/6
$lq =~ /^the number of body parts in the list (.*?) is\?$/ or $lq =~ /^the list (.*?) contains how many body parts\?$/ or $lq =~ /^(.*?): how many body parts in the list\?$/
l!l&&r!l&&!r
3142
$lq =~ /^the number of body parts in the list (.*?) is\?$/ or $lq =~ /^the list (.*?) contains how many body parts\?$/
l!l&&r!l&&!r
2143
MC/DC100%3/3
$lq =~ /^the number of body parts in the list (.*?) is\?$/ or $lq =~ /^the list (.*?) contains how many body parts\?$/ or $lq =~ /^(.*?): how many body parts in the list\?$/
$lq =~ /^the number of body parts in the list (.*?) is\?$/ $lq =~ /^the list (.*?) contains how many body parts\?$/ $lq =~ /^(.*?): how many body parts in the list\?$/
Truth table100%4/4
A or B or C
A= $lq =~ /^the number of body parts in the list (.*?) is\?$/B= $lq =~ /^the list (.*?) contains how many body parts\?$/C= $lq =~ /^(.*?): how many body parts in the list\?$/
ABCresult
1XX1
01X1
0011
0000
154 or $lq =~ /^the list (.*?) contains how many body parts\?$/
155 or $lq =~ /^(.*?): how many body parts in the list\?$/
156 ) {
157 4 return 0 + grep { $body_part{$_} } split /\W+/, $1;
158 }
159 42 ▶ if ($lq =~ /^the body part in (.*?) is\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^the body part in (.*?) is\?$/ or $lq =~ /^which of these is a body part: (.*?)\?$/ or $lq =~ /^which of (.*?) is a body part\?$/ or $lq =~ /^which of (.*?) is part of a person\?$/ or $lq =~ /^(.*?): the body part is\?$/) 6 36 42
Condition100%12/12
$lq =~ /^the body part in (.*?) is\?$/ or $lq =~ /^which of these is a body part: (.*?)\?$/ or $lq =~ /^which of (.*?) is a body part\?$/ or $lq =~ /^which of (.*?) is part of a person\?$/ or $lq =~ /^(.*?): the body part is\?$/
l!l&&r!l&&!r
5136
$lq =~ /^the body part in (.*?) is\?$/ or $lq =~ /^which of these is a body part: (.*?)\?$/ or $lq =~ /^which of (.*?) is a body part\?$/ or $lq =~ /^which of (.*?) is part of a person\?$/
l!l&&r!l&&!r
4137
$lq =~ /^the body part in (.*?) is\?$/ or $lq =~ /^which of these is a body part: (.*?)\?$/ or $lq =~ /^which of (.*?) is a body part\?$/
l!l&&r!l&&!r
3138
$lq =~ /^the body part in (.*?) is\?$/ or $lq =~ /^which of these is a body part: (.*?)\?$/
l!l&&r!l&&!r
2139
MC/DC100%5/5
$lq =~ /^the body part in (.*?) is\?$/ or $lq =~ /^which of these is a body part: (.*?)\?$/ or $lq =~ /^which of (.*?) is a body part\?$/ or $lq =~ /^which of (.*?) is part of a person\?$/ or $lq =~ /^(.*?): the body part is\?$/
$lq =~ /^the body part in (.*?) is\?$/ $lq =~ /^which of these is a body part: (.*?)\?$/ $lq =~ /^which of (.*?) is a body part\?$/ $lq =~ /^which of (.*?) is part of a person\?$/ $lq =~ /^(.*?): the body part is\?$/
Truth table100%6/6
A or B or C or D or E
A= $lq =~ /^the body part in (.*?) is\?$/B= $lq =~ /^which of these is a body part: (.*?)\?$/C= $lq =~ /^which of (.*?) is a body part\?$/D= $lq =~ /^which of (.*?) is part of a person\?$/E= $lq =~ /^(.*?): the body part is\?$/
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
160 or $lq =~ /^which of these is a body part: (.*?)\?$/
161 or $lq =~ /^which of (.*?) is a body part\?$/
162 or $lq =~ /^which of (.*?) is part of a person\?$/
163 or $lq =~ /^(.*?): the body part is\?$/
164 ) {
165 6 ▶ return first { $body_part{$_} } split /(?:,\s*| or )/, $1;
Subroutine __ANON__: called CC=1 SCAR=0.0
166 }
167 36 ▶ if ($lq =~ /^(.*?) is part of the head\?$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^(.*?) is part of the head\?$/) 3 33 36
168 3 ▶ return first { $head_part{$_} } split /\W+/, $1;
Subroutine __ANON__: called CC=1 SCAR=0.0
169 }
170 33 ▶ if ($lq =~ /^(.*?) is something each person has more than one of\?$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^(.*?) is something each person has more than one of\?$/) 3 30 33
171 3 ▶ return first { $multiple_part{$_} } split /\W+/, $1;
Subroutine __ANON__: called CC=1 SCAR=0.0
172 }
173 30 ▶ if ($lq =~ /^(.*?) is above the waist\?$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^(.*?) is above the waist\?$/) 3 27 30
174 3 ▶ return first { $part_above_waist{$_} } split /\W+/, $1;
Subroutine __ANON__: called CC=1 SCAR=0.0
175 }
176 27 ▶ if ($lq =~ /^(.*?) is below the waist\?$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^(.*?) is below the waist\?$/) 3 24 27
177 3 ▶ return first { $part_below_waist{$_} } split /\W+/, $1;
Subroutine __ANON__: called CC=1 SCAR=0.0
178 }
179  
180 # Numbers and digits
181 24 ▶ if ($lq =~ /^enter the number (.*?) in digits:$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^enter the number (.*?) in digits:$/ or $lq =~ /^what is (.*?) as (?:digits|a number)\?$/) 1 23 24
Condition66%2/3
$lq =~ /^enter the number (.*?) in digits:$/ or $lq =~ /^what is (.*?) as (?:digits|a number)\?$/
l!l&&r!l&&!r
1023
MC/DC50%1/2
$lq =~ /^enter the number (.*?) in digits:$/ or $lq =~ /^what is (.*?) as (?:digits|a number)\?$/
$lq =~ /^enter the number (.*?) in digits:$/ $lq =~ /^what is (.*?) as (?:digits|a number)\?$/
Truth table66%2/3
A or B
A= $lq =~ /^enter the number (.*?) in digits:$/B= $lq =~ /^what is (.*?) as (?:digits|a number)\?$/
ABresult
1X1
011
000
182 or $lq =~ /^what is (.*?) as (?:digits|a number)\?$/
183 ) {
184 1 return words2nums $1;
185 }
186 23 ▶ if ($lq =~ /^which digit is (?<p>\d+)\S+ in the number (?<n>\d+)\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^which digit is (?<p>\d+)\S+ in the number (?<n>\d+)\?$/ or $lq =~ /^what is the (?<p>\d+)\S+ digit in (?<n>\d+)\?$/ or $lq =~ /^in the number (?<n>\d+), what is the (?<p>\d+)\S+ digit\?$/) 4 19 23
Condition83%5/6
$lq =~ /^which digit is (?<p>\d+)\S+ in the number (?<n>\d+)\?$/ or $lq =~ /^what is the (?<p>\d+)\S+ digit in (?<n>\d+)\?$/ or $lq =~ /^in the number (?<n>\d+), what is the (?<p>\d+)\S+ digit\?$/
l!l&&r!l&&!r
1319
$lq =~ /^which digit is (?<p>\d+)\S+ in the number (?<n>\d+)\?$/ or $lq =~ /^what is the (?<p>\d+)\S+ digit in (?<n>\d+)\?$/
l!l&&r!l&&!r
1022
MC/DC66%2/3
$lq =~ /^which digit is (?<p>\d+)\S+ in the number (?<n>\d+)\?$/ or $lq =~ /^what is the (?<p>\d+)\S+ digit in (?<n>\d+)\?$/ or $lq =~ /^in the number (?<n>\d+), what is the (?<p>\d+)\S+ digit\?$/
$lq =~ /^which digit is (?<p>\d+)\S+ in the number (?<n>\d+)\?$/ $lq =~ /^what is the (?<p>\d+)\S+ digit in (?<n>\d+)\?$/ $lq =~ /^in the number (?<n>\d+), what is the (?<p>\d+)\S+ digit\?$/
Truth table75%3/4
A or B or C
A= $lq =~ /^which digit is (?<p>\d+)\S+ in the number (?<n>\d+)\?$/B= $lq =~ /^what is the (?<p>\d+)\S+ digit in (?<n>\d+)\?$/C= $lq =~ /^in the number (?<n>\d+), what is the (?<p>\d+)\S+ digit\?$/
ABCresult
1XX1
01X1
0011
0000
187 or $lq =~ /^what is the (?<p>\d+)\S+ digit in (?<n>\d+)\?$/
188 or $lq =~ /^in the number (?<n>\d+), what is the (?<p>\d+)\S+ digit\?$/
189 ) {
190 4 ▶ return $+{p} > length $+{n} ? undef : substr $+{n}, $+{p} - 1, 1;
Branch: 1 branch
BranchTrueFalseTotal
$+{'p'} > length $+{'n'} ? : 1 3 4
191 }
192 19 ▶ if ($lq =~ /^the (?<p>\d+)\S+ number from (?<l>.*?) is\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^the (?<p>\d+)\S+ number from (?<l>.*?) is\?$/ or $lq =~ /^what is the (?<p>\d+)\S+ number in the list (?<l>.*?)\?$/ or $lq =~ /^what number is (?<p>\d+)\S+ in the series (?<l>.*?)\?$/ or $lq =~ /^(?<l>.*?): the (?<p>\d+)\S+ number is\?$/) 5 14 19
Condition100%9/9
$lq =~ /^the (?<p>\d+)\S+ number from (?<l>.*?) is\?$/ or $lq =~ /^what is the (?<p>\d+)\S+ number in the list (?<l>.*?)\?$/ or $lq =~ /^what number is (?<p>\d+)\S+ in the series (?<l>.*?)\?$/ or $lq =~ /^(?<l>.*?): the (?<p>\d+)\S+ number is\?$/
l!l&&r!l&&!r
4114
$lq =~ /^the (?<p>\d+)\S+ number from (?<l>.*?) is\?$/ or $lq =~ /^what is the (?<p>\d+)\S+ number in the list (?<l>.*?)\?$/ or $lq =~ /^what number is (?<p>\d+)\S+ in the series (?<l>.*?)\?$/
l!l&&r!l&&!r
3115
$lq =~ /^the (?<p>\d+)\S+ number from (?<l>.*?) is\?$/ or $lq =~ /^what is the (?<p>\d+)\S+ number in the list (?<l>.*?)\?$/
l!l&&r!l&&!r
2116
MC/DC100%4/4
$lq =~ /^the (?<p>\d+)\S+ number from (?<l>.*?) is\?$/ or $lq =~ /^what is the (?<p>\d+)\S+ number in the list (?<l>.*?)\?$/ or $lq =~ /^what number is (?<p>\d+)\S+ in the series (?<l>.*?)\?$/ or $lq =~ /^(?<l>.*?): the (?<p>\d+)\S+ number is\?$/
$lq =~ /^the (?<p>\d+)\S+ number from (?<l>.*?) is\?$/ $lq =~ /^what is the (?<p>\d+)\S+ number in the list (?<l>.*?)\?$/ $lq =~ /^what number is (?<p>\d+)\S+ in the series (?<l>.*?)\?$/ $lq =~ /^(?<l>.*?): the (?<p>\d+)\S+ number is\?$/
Truth table100%5/5
A or B or C or D
A= $lq =~ /^the (?<p>\d+)\S+ number from (?<l>.*?) is\?$/B= $lq =~ /^what is the (?<p>\d+)\S+ number in the list (?<l>.*?)\?$/C= $lq =~ /^what number is (?<p>\d+)\S+ in the series (?<l>.*?)\?$/D= $lq =~ /^(?<l>.*?): the (?<p>\d+)\S+ number is\?$/
ABCDresult
1XXX1
01XX1
001X1
00011
00000
193 or $lq =~ /^what is the (?<p>\d+)\S+ number in the list (?<l>.*?)\?$/
194 or $lq =~ /^what number is (?<p>\d+)\S+ in the series (?<l>.*?)\?$/
195 or $lq =~ /^(?<l>.*?): the (?<p>\d+)\S+ number is\?$/
196 ) {
197 5 my @nums = map { words2nums $_ } split /(?:,\s*| and )/, $+{l};
198 5 return $nums[ $+{p} - 1 ];
199 }
200 14 state $biggest_re = qr/(?:biggest | largest | highest)/x;
201 14 ▶ if ($lq =~ /^enter the $biggest_re number of (.*?):$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^enter the $biggest_re number of (.*?):$/ or $lq =~ /^of the numbers (.*?), which is the $biggest_re\?$/ or $lq =~ /^which of (.*?) is the $biggest_re\?$/ or $lq =~ /^(.*?): which of these is the $biggest_re\?$/ or $lq =~ /^(.*?): the $biggest_re is\?$/) 5 9 14
Condition100%12/12
$lq =~ /^enter the $biggest_re number of (.*?):$/ or $lq =~ /^of the numbers (.*?), which is the $biggest_re\?$/ or $lq =~ /^which of (.*?) is the $biggest_re\?$/ or $lq =~ /^(.*?): which of these is the $biggest_re\?$/ or $lq =~ /^(.*?): the $biggest_re is\?$/
l!l&&r!l&&!r
419
$lq =~ /^enter the $biggest_re number of (.*?):$/ or $lq =~ /^of the numbers (.*?), which is the $biggest_re\?$/ or $lq =~ /^which of (.*?) is the $biggest_re\?$/ or $lq =~ /^(.*?): which of these is the $biggest_re\?$/
l!l&&r!l&&!r
3110
$lq =~ /^enter the $biggest_re number of (.*?):$/ or $lq =~ /^of the numbers (.*?), which is the $biggest_re\?$/ or $lq =~ /^which of (.*?) is the $biggest_re\?$/
l!l&&r!l&&!r
2111
$lq =~ /^enter the $biggest_re number of (.*?):$/ or $lq =~ /^of the numbers (.*?), which is the $biggest_re\?$/
l!l&&r!l&&!r
1112
MC/DC100%5/5
$lq =~ /^enter the $biggest_re number of (.*?):$/ or $lq =~ /^of the numbers (.*?), which is the $biggest_re\?$/ or $lq =~ /^which of (.*?) is the $biggest_re\?$/ or $lq =~ /^(.*?): which of these is the $biggest_re\?$/ or $lq =~ /^(.*?): the $biggest_re is\?$/
$lq =~ /^enter the $biggest_re number of (.*?):$/ $lq =~ /^of the numbers (.*?), which is the $biggest_re\?$/ $lq =~ /^which of (.*?) is the $biggest_re\?$/ $lq =~ /^(.*?): which of these is the $biggest_re\?$/ $lq =~ /^(.*?): the $biggest_re is\?$/
Truth table100%6/6
A or B or C or D or E
A= $lq =~ /^enter the $biggest_re number of (.*?):$/B= $lq =~ /^of the numbers (.*?), which is the $biggest_re\?$/C= $lq =~ /^which of (.*?) is the $biggest_re\?$/D= $lq =~ /^(.*?): which of these is the $biggest_re\?$/E= $lq =~ /^(.*?): the $biggest_re is\?$/
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
202 or $lq =~ /^of the numbers (.*?), which is the $biggest_re\?$/
203 or $lq =~ /^which of (.*?) is the $biggest_re\?$/
204 or $lq =~ /^(.*?): which of these is the $biggest_re\?$/
205 or $lq =~ /^(.*?): the $biggest_re is\?$/
206 ) {
207 5 return max map { words2nums $_ } split /(?:,\s*| or )/, $1;
208 }
209 9 state $smallest_re = qr/(?:smallest | lowest)/x;
210 9 ▶ if ($lq =~ /^enter the $smallest_re number of (.*?):$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^enter the $smallest_re number of (.*?):$/ or $lq =~ /^of the numbers (.*?), which is the $smallest_re\?$/ or $lq =~ /^which of (.*?) is the $smallest_re\?$/ or $lq =~ /^(.*?): which of these is the $smallest_re\?$/ or $lq =~ /^(.*?): the $smallest_re is\?$/) 5 4 9
Condition100%12/12
$lq =~ /^enter the $smallest_re number of (.*?):$/ or $lq =~ /^of the numbers (.*?), which is the $smallest_re\?$/ or $lq =~ /^which of (.*?) is the $smallest_re\?$/ or $lq =~ /^(.*?): which of these is the $smallest_re\?$/ or $lq =~ /^(.*?): the $smallest_re is\?$/
l!l&&r!l&&!r
414
$lq =~ /^enter the $smallest_re number of (.*?):$/ or $lq =~ /^of the numbers (.*?), which is the $smallest_re\?$/ or $lq =~ /^which of (.*?) is the $smallest_re\?$/ or $lq =~ /^(.*?): which of these is the $smallest_re\?$/
l!l&&r!l&&!r
315
$lq =~ /^enter the $smallest_re number of (.*?):$/ or $lq =~ /^of the numbers (.*?), which is the $smallest_re\?$/ or $lq =~ /^which of (.*?) is the $smallest_re\?$/
l!l&&r!l&&!r
216
$lq =~ /^enter the $smallest_re number of (.*?):$/ or $lq =~ /^of the numbers (.*?), which is the $smallest_re\?$/
l!l&&r!l&&!r
117
MC/DC100%5/5
$lq =~ /^enter the $smallest_re number of (.*?):$/ or $lq =~ /^of the numbers (.*?), which is the $smallest_re\?$/ or $lq =~ /^which of (.*?) is the $smallest_re\?$/ or $lq =~ /^(.*?): which of these is the $smallest_re\?$/ or $lq =~ /^(.*?): the $smallest_re is\?$/
$lq =~ /^enter the $smallest_re number of (.*?):$/ $lq =~ /^of the numbers (.*?), which is the $smallest_re\?$/ $lq =~ /^which of (.*?) is the $smallest_re\?$/ $lq =~ /^(.*?): which of these is the $smallest_re\?$/ $lq =~ /^(.*?): the $smallest_re is\?$/
Truth table100%6/6
A or B or C or D or E
A= $lq =~ /^enter the $smallest_re number of (.*?):$/B= $lq =~ /^of the numbers (.*?), which is the $smallest_re\?$/C= $lq =~ /^which of (.*?) is the $smallest_re\?$/D= $lq =~ /^(.*?): which of these is the $smallest_re\?$/E= $lq =~ /^(.*?): the $smallest_re is\?$/
ABCDEresult
1XXXX1
01XXX1
001XX1
0001X1
000011
000000
211 or $lq =~ /^of the numbers (.*?), which is the $smallest_re\?$/
212 or $lq =~ /^which of (.*?) is the $smallest_re\?$/
213 or $lq =~ /^(.*?): which of these is the $smallest_re\?$/
214 or $lq =~ /^(.*?): the $smallest_re is\?$/
215 ) {
216 5 return min map { words2nums $_ } split /(?:,\s*| or )/, $1;
217 }
218 4 ▶ if ($lq =~ /^(.*?) (?:= |equals |is what)\?$/
Branch: 1 branch
BranchTrueFalseTotal
if ($lq =~ /^(.*?) (?:= |equals |is what)\?$/ or $lq =~ /^what(?:'s| is) (.*?)\?$/) 4 0 4
Condition33%1/3
$lq =~ /^(.*?) (?:= |equals |is what)\?$/ or $lq =~ /^what(?:'s| is) (.*?)\?$/
l!l&&r!l&&!r
400
MC/DC0%0/2
$lq =~ /^(.*?) (?:= |equals |is what)\?$/ or $lq =~ /^what(?:'s| is) (.*?)\?$/
$lq =~ /^(.*?) (?:= |equals |is what)\?$/ $lq =~ /^what(?:'s| is) (.*?)\?$/
Truth table33%1/3
A or B
A= $lq =~ /^(.*?) (?:= |equals |is what)\?$/B= $lq =~ /^what(?:'s| is) (.*?)\?$/
ABresult
1X1
011
000
219 or $lq =~ /^what(?:'s| is) (.*?)\?$/
220 ) {
221 4 my $expr = $1;
222 4 ▶ s/\b(?:add|plus)\b/+/ or s/\bminus\b/-/ for $expr;
Branch: 1 branch
BranchTrueFalseTotal
s/\b(?:add|plus)\b/+/ or s/\bminus\b/-/ 3 1 4
223 4 ▶ $expr =~ s{\b(\w+)\b}{ words2nums($1) // $1 }eg;
Condition33%1/3
&words2nums($1) // $1
l!l&&r!l&&!r
800
MC/DC0%0/2
&words2nums($1) // $1
&words2nums($1) $1
Truth table33%1/3
A // B
A= &words2nums($1)B= $1
ABresult
1X1
011
000
224 4 ▶ return eval $expr if $expr =~ /^[ \d+-]+$/;
Branch: 1 branch
BranchTrueFalseTotal
if $expr =~ /^[ \d+-]+$/ 4 0 4
225 }
226  
227 0 return;
228 }
229  
230  
231 2 1;
232  
233 __END__
↑ Summary