Skip to content
Extraits de code Groupes Projets
Valider a9a09bb7 rédigé par Alexandre Morignot's avatar Alexandre Morignot
Parcourir les fichiers

remove all occurencies of context

parent 765e21bf
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -120,7 +120,7 @@ sub exec {
$sth = $dbh->prepare("select group_concat(tag separator ' ')
from playbot_tags
where id = ? and context = 0
where id = ?
group by id");
$sth->execute($content->[0]);
......
......@@ -4,8 +4,6 @@ require Exporter;
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(exec);
use Lingua::StopWords qw(getStopWords);
our $dbh;
our $log;
......@@ -17,37 +15,19 @@ sub exec {
}
}
sub addContext
{
my ($id, $msg) = @_;
while ($msg =~ /#?([a-zA-Z0-9_-]+)/g) {
addTag($id, $1, 1);
}
}
sub addTag
{
my ($id, $tag, $context) = @_;
my ($id, $tag) = @_;
my $stopwords_en = getStopWords('en');
my $stopwords_fr = getStopWords('fr');
return if ($context and ($stopwords_en->{lc $tag} or $stopwords_fr->{lc $tag}));
my $sth;
if (!$context) {
$sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag, context)
VALUES (?, ?, ?)
ON DUPLICATE KEY
UPDATE context = 0');
} else {
$sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag, context)
VALUES (?, ?, ?)');
}
$sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag)
VALUES (?, ?)');
$log->error("Couldn't prepare querie; aborting") unless (defined $sth);
$sth->execute($id, $tag, ($context) ? 1 : 0)
$sth->execute($id, $tag)
or $log->error("Couldn't finish transaction: " . $dbh->errstr);
}
......
......@@ -80,9 +80,6 @@ sub parse {
or $log->error("Couldn't finish transaction: " . $dbh->errstr);
$id = $sth->fetch->[0];
# we don't want to reinsert the context, so we delete it
delete $content{'context'};
}
# message sur irc
......@@ -101,10 +98,6 @@ sub parse {
$sth->execute($id, $chan->[0])
or $log->error("Couldn't finish transaction: " . $dbh->errstr);
if (defined $content{'context'}) {
commands::tag::addContext($id, $content{'context'});
}
}
return $id;
......
......@@ -30,16 +30,6 @@ sub get {
$infos{'ddl'} = $content->{'download_url'};
}
my $context = $content->{'tag_list'}.' '.$content->{'description'};
$context = $context.' '.$infos{'title'}.' '.$infos{'author'};
my $finder = URI::Find->new( sub { '' } );
# we remove the URI and the punctuation
$finder->find(\$context);
$context =~ s/[[:punct:]]/ /g;
$infos{'context'} = $context;
return %infos;
}
......
......@@ -21,17 +21,6 @@ sub get {
$infos{'author'} = $video->uploader;
$infos{'url'} = $video->base_uri;
=cut
my $context = decode("UTF-8", $video->description) . ' ' . $infos{'title'};
my $finder = URI::Find->new( sub { '' } );
# we remove the URI and the punctuation
$finder->find(\$context);
$context =~ s/[[:punct:]]/ /g;
$infos{'context'} = $context;
=cut
return %infos;
}
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter