line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBD::SQLite::FTS3Transitional;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
53551
|
use 5.006;
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings;
|
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
30
|
|
6
|
1
|
|
|
1
|
|
4
|
no warnings 'uninitialized';
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
7
|
1
|
|
|
1
|
|
10
|
use Exporter ();
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
317
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.00';
|
10
|
|
|
|
|
|
|
our @ISA = 'Exporter';
|
11
|
|
|
|
|
|
|
our @EXPORT_OK = qw/fts3_convert/;
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub fts3_convert {
|
14
|
6
|
|
|
6
|
1
|
3741
|
my $in = shift;
|
15
|
6
|
|
|
|
|
10
|
my $out = "";
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# decompose input string into tokens
|
18
|
6
|
|
|
|
|
60
|
my @tokens = $in =~ / - # minus sign
|
19
|
|
|
|
|
|
|
| \bOR\b # OR keyword
|
20
|
|
|
|
|
|
|
| ".*?" # phrase query
|
21
|
|
|
|
|
|
|
| \S+ # term
|
22
|
|
|
|
|
|
|
/xg;
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# build the output string
|
25
|
6
|
|
|
|
|
19
|
while (@tokens) {
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# -a => (NOT a)
|
28
|
13
|
100
|
100
|
|
|
63
|
if ($tokens[0] eq '-') {
|
|
|
100
|
|
|
|
|
|
29
|
3
|
|
|
|
|
11
|
my (undef, $right) = splice(@tokens, 0, 2);
|
30
|
3
|
|
|
|
|
13
|
$out .= " (NOT $right)";
|
31
|
|
|
|
|
|
|
}
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# a OR b => (a OR b)
|
34
|
|
|
|
|
|
|
elsif (@tokens >= 2 && $tokens[1] eq 'OR') {
|
35
|
3
|
|
|
|
|
8
|
my ($left, undef, $right) = splice(@tokens, 0, 3);
|
36
|
3
|
100
|
|
|
|
9
|
if ($right eq '-') {
|
37
|
1
|
|
|
|
|
3
|
$right = "NOT " . shift @tokens;
|
38
|
|
|
|
|
|
|
}
|
39
|
3
|
|
|
|
|
13
|
$out .= " ($left OR $right)";
|
40
|
|
|
|
|
|
|
}
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# plain term
|
43
|
|
|
|
|
|
|
else {
|
44
|
7
|
|
|
|
|
25
|
$out .= " " . shift @tokens;
|
45
|
|
|
|
|
|
|
}
|
46
|
|
|
|
|
|
|
}
|
47
|
|
|
|
|
|
|
|
48
|
6
|
|
|
|
|
19
|
return $out;
|
49
|
|
|
|
|
|
|
}
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1;
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__
|