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
Branches
Étiquettes
Aucune requête de fusion associée trouvée
...@@ -120,7 +120,7 @@ sub exec { ...@@ -120,7 +120,7 @@ sub exec {
$sth = $dbh->prepare("select group_concat(tag separator ' ') $sth = $dbh->prepare("select group_concat(tag separator ' ')
from playbot_tags from playbot_tags
where id = ? and context = 0 where id = ?
group by id"); group by id");
$sth->execute($content->[0]); $sth->execute($content->[0]);
......
...@@ -4,8 +4,6 @@ require Exporter; ...@@ -4,8 +4,6 @@ require Exporter;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT_OK = qw(exec); our @EXPORT_OK = qw(exec);
use Lingua::StopWords qw(getStopWords);
our $dbh; our $dbh;
our $log; our $log;
...@@ -17,37 +15,19 @@ sub exec { ...@@ -17,37 +15,19 @@ sub exec {
} }
} }
sub addContext
{
my ($id, $msg) = @_;
while ($msg =~ /#?([a-zA-Z0-9_-]+)/g) {
addTag($id, $1, 1);
}
}
sub addTag sub addTag
{ {
my ($id, $tag, $context) = @_; my ($id, $tag) = @_;
my $stopwords_en = getStopWords('en'); my $stopwords_en = getStopWords('en');
my $stopwords_fr = getStopWords('fr'); my $stopwords_fr = getStopWords('fr');
return if ($context and ($stopwords_en->{lc $tag} or $stopwords_fr->{lc $tag}));
my $sth; my $sth;
if (!$context) { $sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag)
$sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag, context) VALUES (?, ?)');
VALUES (?, ?, ?)
ON DUPLICATE KEY
UPDATE context = 0');
} else {
$sth = $dbh->prepare_cached('INSERT INTO playbot_tags (id, tag, context)
VALUES (?, ?, ?)');
}
$log->error("Couldn't prepare querie; aborting") unless (defined $sth); $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); or $log->error("Couldn't finish transaction: " . $dbh->errstr);
} }
......
...@@ -80,9 +80,6 @@ sub parse { ...@@ -80,9 +80,6 @@ sub parse {
or $log->error("Couldn't finish transaction: " . $dbh->errstr); or $log->error("Couldn't finish transaction: " . $dbh->errstr);
$id = $sth->fetch->[0]; $id = $sth->fetch->[0];
# we don't want to reinsert the context, so we delete it
delete $content{'context'};
} }
# message sur irc # message sur irc
...@@ -101,10 +98,6 @@ sub parse { ...@@ -101,10 +98,6 @@ sub parse {
$sth->execute($id, $chan->[0]) $sth->execute($id, $chan->[0])
or $log->error("Couldn't finish transaction: " . $dbh->errstr); or $log->error("Couldn't finish transaction: " . $dbh->errstr);
if (defined $content{'context'}) {
commands::tag::addContext($id, $content{'context'});
}
} }
return $id; return $id;
......
...@@ -30,16 +30,6 @@ sub get { ...@@ -30,16 +30,6 @@ sub get {
$infos{'ddl'} = $content->{'download_url'}; $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; return %infos;
} }
......
...@@ -21,17 +21,6 @@ sub get { ...@@ -21,17 +21,6 @@ sub get {
$infos{'author'} = $video->uploader; $infos{'author'} = $video->uploader;
$infos{'url'} = $video->base_uri; $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; 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