3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-26 13:59:47 +01:00

Levenshtein distance increased from 50% to 60%; Levenshtein searches all channels on unfound factoid

This commit is contained in:
Pragmatic Software 2010-06-30 10:59:50 +00:00
parent def3b6eae7
commit c6e48954c5
4 changed files with 5 additions and 7 deletions

View File

@ -234,7 +234,7 @@ sub levenshtein_matches {
my $distance = fastdistance($secondary_index_key, $index); my $distance = fastdistance($secondary_index_key, $index);
my $length = (length($secondary_index_key) > length($index)) ? length $secondary_index_key : length $index; my $length = (length($secondary_index_key) > length($index)) ? length $secondary_index_key : length $index;
if($distance / $length < 0.50) { if($distance / $length < 0.60) {
$result .= $comma . $index; $result .= $comma . $index;
$comma = ", "; $comma = ", ";
} }

View File

@ -275,8 +275,7 @@ sub factadd {
if(defined $trigger) { if(defined $trigger) {
$self->{pbot}->logger->log("$nick!$user\@$host attempt to overwrite $keyword\n"); $self->{pbot}->logger->log("$nick!$user\@$host attempt to overwrite $keyword\n");
return undef; return "/msg $nick $keyword already exists for " . ($from_chan eq '.*' ? 'global channel' : $from_chan) . ".";
return "/msg $nick $keyword already exists.";
} }
$self->{pbot}->factoids->add_factoid('text', $from_chan, $nick, $keyword, $text); $self->{pbot}->factoids->add_factoid('text', $from_chan, $nick, $keyword, $text);

View File

@ -13,7 +13,6 @@ $VERSION = $PBot::PBot::VERSION;
use HTML::Entities; use HTML::Entities;
use Time::HiRes qw(gettimeofday); use Time::HiRes qw(gettimeofday);
use Text::Levenshtein qw(fastdistance);
use Carp (); use Carp ();
use PBot::FactoidModuleLauncher; use PBot::FactoidModuleLauncher;
@ -204,7 +203,7 @@ sub interpreter {
($channel, $keyword) = $self->find_factoid($from, $keyword, $arguments); ($channel, $keyword) = $self->find_factoid($from, $keyword, $arguments);
if(not defined $keyword) { if(not defined $keyword) {
my $matches = $self->factoids->levenshtein_matches($from, lc $original_keyword); my $matches = $self->factoids->levenshtein_matches('.*', lc $original_keyword);
return undef if $matches eq 'none'; return undef if $matches eq 'none';

View File

@ -13,8 +13,8 @@ use warnings;
# These are set automatically by the build/commit script # These are set automatically by the build/commit script
use constant { use constant {
BUILD_NAME => "PBot", BUILD_NAME => "PBot",
BUILD_REVISION => 222, BUILD_REVISION => 223,
BUILD_DATE => "2010-06-29", BUILD_DATE => "2010-06-30",
}; };
1; 1;