mirror of
https://github.com/perlbot/perlbuut
synced 2025-06-07 18:25:42 -04:00
Change sorting and such so that we handle thread=>threads better
This commit is contained in:
parent
26c2bfe8ae
commit
20b3e16359
2 changed files with 5 additions and 3 deletions
|
@ -24,7 +24,6 @@ server "*" {
|
||||||
plugin "eval" {addressed: false; }
|
plugin "eval" {addressed: false; }
|
||||||
plugin "deparse" {addressed: false; }
|
plugin "deparse" {addressed: false; }
|
||||||
plugin "badfacts" {addressed: false; }
|
plugin "badfacts" {addressed: false; }
|
||||||
plugin "default" {plugin: "nfacts"}
|
|
||||||
}
|
}
|
||||||
channel "#buubot" {
|
channel "#buubot" {
|
||||||
plugin "eval" {addressed: false; }
|
plugin "eval" {addressed: false; }
|
||||||
|
@ -42,6 +41,7 @@ server "*.freenode.net" {
|
||||||
serverspace: "freenode.net";
|
serverspace: "freenode.net";
|
||||||
filtersep: false;
|
filtersep: false;
|
||||||
}
|
}
|
||||||
|
plugin "default" {plugin: "factoid"; }
|
||||||
}
|
}
|
||||||
channel "#regex" {
|
channel "#regex" {
|
||||||
plugin "nfacts" {
|
plugin "nfacts" {
|
||||||
|
|
|
@ -651,14 +651,16 @@ sub _metaphone_matches {
|
||||||
# TODO this needs to be rewritten to do an edit distance based on the metaphone columns, rather than a direct comparison
|
# TODO this needs to be rewritten to do an edit distance based on the metaphone columns, rather than a direct comparison
|
||||||
#XXX HACK WARNING: not really a hack, but something to document, the inner query here seems to work fine on sqlite, but i suspect on other databases it might need an ORDER BY factoid_id clause to enforce that it picks the last entry in the database
|
#XXX HACK WARNING: not really a hack, but something to document, the inner query here seems to work fine on sqlite, but i suspect on other databases it might need an ORDER BY factoid_id clause to enforce that it picks the last entry in the database
|
||||||
my $rows = $dbh->selectall_arrayref(
|
my $rows = $dbh->selectall_arrayref(
|
||||||
"SELECT f.factoid_id, f.subject, f.predicate, f.metaphone, spellfix1_editdist(f.metaphone, ?) AS score FROM (SELECT max(factoid_id) AS factoid_id FROM factoid GROUP BY subject) as subquery JOIN factoid AS f USING (factoid_id) WHERE NOT (f.predicate = ' ') AND f.predicate IS NOT NULL AND length(f.metaphone) > 1 ORDER BY score ASC LIMIT 10;",
|
"SELECT f.factoid_id, f.subject, f.predicate, f.metaphone, spellfix1_editdist(f.metaphone, ?) AS score FROM (SELECT max(factoid_id) AS factoid_id FROM factoid GROUP BY subject) as subquery JOIN factoid AS f USING (factoid_id) WHERE NOT (f.predicate = ' ') AND f.predicate IS NOT NULL AND length(f.metaphone) > 1 AND score < 200 ORDER BY score ASC;",
|
||||||
undef,
|
undef,
|
||||||
$metaphone
|
$metaphone
|
||||||
);
|
);
|
||||||
|
|
||||||
use Text::Levenshtein qw/distance/; # only import it in this scope
|
use Text::Levenshtein qw/distance/; # only import it in this scope
|
||||||
|
|
||||||
return [ map {$_->[0]} sort {$a->[1] <=> $b->[1]} map {[$_->[1], distance($subject, $_->[1])]} grep {$_->[2] =~ /\S/} @$rows ];
|
my @sorted = map {$_->[0]} sort {$a->[1] <=> $b->[1]} map {[$_->[1], distance($subject, $_->[1])]} grep {$_->[2] =~ /\S/} @$rows ;
|
||||||
|
|
||||||
|
return [@sorted[0..9]];
|
||||||
}
|
}
|
||||||
|
|
||||||
no warnings 'void';
|
no warnings 'void';
|
||||||
|
|
Loading…
Add table
Reference in a new issue