1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-07 18:35:49 -04:00

work on factoid edit threshold

This commit is contained in:
Ryan Voots 2019-09-26 16:40:04 -04:00
parent 9d630e2e56
commit 608766f8f8
3 changed files with 8 additions and 3 deletions

View file

@ -8,6 +8,7 @@ use strict;
use Encode qw/decode/;
use Data::Dumper;
use List::Util qw/min max/;
#############################
# BIG WARNING ABOUT THE DATABASE IN HERE.
@ -840,9 +841,9 @@ sub _metaphone_matches {
$metaphone
);
use Text::Levenshtein qw/distance/; # only import it in this scope
use Text::Levenshtein qw/distance/; # only import it in this scope
my $threshold = 4;
my $threshold = int(max(4, min(10, 4+length($subject)/7)));
my @sorted = map {$_->[0]} sort {$a->[1] <=> $b->[1]} grep {$_->[1] < $threshold} map {[$_->[1], distance($subject, $_->[1])]} grep {$_->[2] =~ /\S/} @$rows ;
return [grep {$_} @sorted[0..9]];

View file

@ -49,6 +49,8 @@ sub command {
my( $self, $said, $pm ) = @_;
my( $target ) = @{ $said->{recommended_args} };
return () unless $said->{addressed};
my $seen = $self->dbh->selectrow_arrayref( "SELECT user,message,seen_date FROM seen WHERE lc_user = ?",
undef,
l_irc( $target )

View file

@ -58,7 +58,7 @@ sub make_pastebin_all {
}
}
my @versions = ('', 't', qw(1 2 3 4 5.0 5.1 5.2 5.3 5.4 5.5 tall all rall), map {$_, $_."t"} qw/5.6 5.8 5.8.4 5.8.8 5.10 5.10.0 5.12 5.14 5.16 5.18 5.20 5.22 5.24 5.26 5.28 5.30/);
my @versions = ('', 't', qw(1 2 3 4 5.0 5.1 5.2 5.3 5.4 5.5 tall all rall yall), map {$_, $_."t"} qw/5.6 5.8 5.8.4 5.8.8 5.10 5.10.0 5.12 5.14 5.16 5.18 5.20 5.22 5.24 5.26 5.28 5.30 5.30.0 5.28.2 5.28.1 5.28.0 5.26.3 5.26.2 5.26.1 5.26.0 5.24.4 5.24.3 5.24.2 5.24.1 5.24.0 5.22.4 5.22.3 5.22.2 5.22.1 5.22.0 5.20.3 5.20.2 5.20.1 5.20.0 5.18.4 5.18.3 5.18.2 5.18.1 5.18.0 5.16.3 5.16.2 5.16.1 5.16.0 5.14.4 5.14.3 5.14.2 5.14.1 5.14.0 5.12.5 5.12.4 5.12.3 5.12.2 5.12.1 5.12.0 5.10.1 5.10.0 5.8.9 5.8.8 5.8.7 5.8.6 5.8.5 5.8.4 5.8.3 5.8.2 5.8.1 5.8.0 5.6.2 5.6.1 5.6.0/);
sub new {
my( $class ) = @_;
@ -176,6 +176,8 @@ sub command {
$resultstr = make_pastebin_all($said->{channel}, $code, "t");
} elsif ($type =~ /perlrall/) {
$resultstr = make_pastebin_all($said->{channel}, $code, "r");
} elsif ($type =~ /perlyall/) {
$resultstr = make_pastebin_all($said->{channel}, $code, "y");
} elsif ($pbflag) {
my $output = $self->do_singleeval($type, $code);
$resultstr = make_pastebin($said->{channel}, $output);