mirror of
https://github.com/perlbot/perlbuut
synced 2025-06-08 02:55:40 -04:00
fixed bug in factoid code suggestions.
also documented logical error in database, won't fix it yet
This commit is contained in:
parent
8b8a24ee6c
commit
93bf662bf9
1 changed files with 14 additions and 1 deletions
|
@ -7,6 +7,18 @@ use strict;
|
||||||
|
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
|
#############################
|
||||||
|
# BIG WARNING ABOUT THE DATABASE IN HERE.
|
||||||
|
#############################
|
||||||
|
#
|
||||||
|
# Despite the name 'original_subject' and 'subject' are logically reversed, e.g. 'original_subject' contains the cleaned up and filtered subject rather than the other way around.
|
||||||
|
# This should be kept in mind when working on any and all of the code below
|
||||||
|
# --simcop2387 (previously also discovered by buu, but not documented or fixed).
|
||||||
|
#
|
||||||
|
# This might be fixed later but for now its easier to just "document" it. (boy doesn't this feel enterprisy!)
|
||||||
|
#
|
||||||
|
#############################
|
||||||
|
|
||||||
my $COPULA = join '|', qw/is are was isn't were being am/, "to be", "will be", "has been", "have been", "shall be", "can has", "wus liek", "iz liek", "used to be";
|
my $COPULA = join '|', qw/is are was isn't were being am/, "to be", "will be", "has been", "have been", "shall be", "can has", "wus liek", "iz liek", "used to be";
|
||||||
my $COPULA_RE = qr/\b(?:$COPULA)\b/i;
|
my $COPULA_RE = qr/\b(?:$COPULA)\b/i;
|
||||||
|
|
||||||
|
@ -489,8 +501,9 @@ sub _soundex_matches {
|
||||||
my( $self, $soundex ) = @_;
|
my( $self, $soundex ) = @_;
|
||||||
my $dbh = $self->dbh;
|
my $dbh = $self->dbh;
|
||||||
|
|
||||||
|
#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 factoid_id,subject,predicate FROM factoid WHERE soundex = ? GROUP BY subject LIMIT 10",
|
"SELECT * FROM (SELECT factoid_id,subject,predicate FROM factoid GROUP BY original_subject) as subquery WHERE NOT (predicate = ' ') AND soundex = ? LIMIT 10",
|
||||||
undef,
|
undef,
|
||||||
$soundex
|
$soundex
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue