mirror of
https://github.com/pragma-/pbot.git
synced 2024-12-23 11:12:42 +01:00
WTF, remove horrendous tabs from my Perl code!
This commit is contained in:
parent
8cb1c128c1
commit
0f6d5663be
@ -99,8 +99,8 @@ print STDERR "Categorizing documents\n";
|
|||||||
for my $i (0 .. $#lines) {
|
for my $i (0 .. $#lines) {
|
||||||
print STDERR "$i\n";
|
print STDERR "$i\n";
|
||||||
|
|
||||||
# Remove/fix stupid things
|
# Remove/fix stupid things
|
||||||
$lines[$i] =~ s/\s*Category:\s*//g;
|
$lines[$i] =~ s/\s*Category:\s*//g;
|
||||||
$lines[$i] =~ s/(\w:)(\w)/$1 $2/g;
|
$lines[$i] =~ s/(\w:)(\w)/$1 $2/g;
|
||||||
$lines[$i] =~ s{/}{ / }g;
|
$lines[$i] =~ s{/}{ / }g;
|
||||||
$lines[$i] =~ s{&}{ & }g;
|
$lines[$i] =~ s{&}{ & }g;
|
||||||
@ -112,26 +112,26 @@ for my $i (0 .. $#lines) {
|
|||||||
|
|
||||||
my @l = split /`/, $lines[$i];
|
my @l = split /`/, $lines[$i];
|
||||||
|
|
||||||
# If the question has an obvious category, use that
|
# If the question has an obvious category, use that
|
||||||
if ($l[0] =~ m/^(.{4,}?)\s*[:-]/) {
|
if ($l[0] =~ m/^(.{4,}?)\s*[:-]/) {
|
||||||
my $cat = $1;
|
my $cat = $1;
|
||||||
my $nspc = () = $cat =~ m/\s+/g;
|
my $nspc = () = $cat =~ m/\s+/g;
|
||||||
if ($nspc < 3) {
|
if ($nspc < 3) {
|
||||||
if (length $cat >= 3 and $cat !~ m/(general|^A |_+)/i) {
|
if (length $cat >= 3 and $cat !~ m/(general|^A |_+)/i) {
|
||||||
$cat =~ s/^\s+|\s+$//g;
|
$cat =~ s/^\s+|\s+$//g;
|
||||||
$cat = uc $cat;
|
$cat = uc $cat;
|
||||||
$cat =~ s/'//g;
|
$cat =~ s/'//g;
|
||||||
$cat =~ s/\.//g;
|
$cat =~ s/\.//g;
|
||||||
$cat =~ s/(?:\s+$|\R|^"|"$|^-|^\[|\]$)//g;
|
$cat =~ s/(?:\s+$|\R|^"|"$|^-|^\[|\]$)//g;
|
||||||
$cat =~ s/\s+/ /g;
|
$cat =~ s/\s+/ /g;
|
||||||
$cat =~ s/(\d+)S/$1'S/g;
|
$cat =~ s/(\d+)S/$1'S/g;
|
||||||
|
|
||||||
$cat =~ s/^SPORT(?!S)/SPORTS/;
|
$cat =~ s/^SPORT(?!S)/SPORTS/;
|
||||||
$cat =~ s/ (?:AND|N|'N) / & /;
|
$cat =~ s/ (?:AND|N|'N) / & /;
|
||||||
#$cat =~ s/\s*\/\s*/\//;
|
#$cat =~ s/\s*\/\s*/\//;
|
||||||
|
|
||||||
$cat =~ s/^GEOGRAPH.*/GEOGRAPHY/;
|
$cat =~ s/^GEOGRAPH.*/GEOGRAPHY/;
|
||||||
$cat = 'STAR TREK' if ($cat =~ m/^STAR TREK/);
|
$cat = 'STAR TREK' if ($cat =~ m/^STAR TREK/);
|
||||||
|
|
||||||
$cat = 'GUESS THE WORD' if $l[0] =~ m/.*: '.*\.'/;
|
$cat = 'GUESS THE WORD' if $l[0] =~ m/.*: '.*\.'/;
|
||||||
|
|
||||||
@ -142,23 +142,23 @@ for my $i (0 .. $#lines) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print STDERR "Using obvious $cat for doc $i: $l[0] ($l[1])\n";
|
print STDERR "Using obvious $cat for doc $i: $l[0] ($l[1])\n";
|
||||||
push @{$docs{$cat}}, $i;
|
push @{$docs{$cat}}, $i;
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $found = 0;
|
my $found = 0;
|
||||||
foreach my $rule (@rules) {
|
foreach my $rule (@rules) {
|
||||||
if ($l[0] =~ m/$rule->{regex}/) {
|
if ($l[0] =~ m/$rule->{regex}/) {
|
||||||
my $cat = uc $rule->{'category'};
|
my $cat = uc $rule->{'category'};
|
||||||
push @{$docs{$cat}}, $i;
|
push @{$docs{$cat}}, $i;
|
||||||
$found = 1;
|
$found = 1;
|
||||||
print STDERR "Using rules $cat for doc $i: $l[0] ($l[1])\n";
|
print STDERR "Using rules $cat for doc $i: $l[0] ($l[1])\n";
|
||||||
last;
|
last;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next if $found;
|
next if $found;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user