From a9a09bb764ff68fc8656db6b7ecf869f49e5d87b Mon Sep 17 00:00:00 2001 From: Alexandre Morignot <erdnaxeli@gmail.com> Date: Sat, 16 Aug 2014 20:40:07 +0200 Subject: [PATCH] remove all occurencies of context --- lib/commands/get.pm | 2 +- lib/commands/tag.pm | 28 ++++------------------------ lib/sites/parser.pm | 7 ------- lib/sites/soundcloud.pm | 10 ---------- lib/sites/youtube.pm | 11 ----------- 5 files changed, 5 insertions(+), 53 deletions(-) diff --git a/lib/commands/get.pm b/lib/commands/get.pm index e93ace8..38ed533 100644 --- a/lib/commands/get.pm +++ b/lib/commands/get.pm @@ -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]); diff --git a/lib/commands/tag.pm b/lib/commands/tag.pm index ec91ce9..ea31e85 100644 --- a/lib/commands/tag.pm +++ b/lib/commands/tag.pm @@ -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); } diff --git a/lib/sites/parser.pm b/lib/sites/parser.pm index a0d1ecb..9a8261b 100644 --- a/lib/sites/parser.pm +++ b/lib/sites/parser.pm @@ -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; diff --git a/lib/sites/soundcloud.pm b/lib/sites/soundcloud.pm index 1cb8eee..d65e6f1 100644 --- a/lib/sites/soundcloud.pm +++ b/lib/sites/soundcloud.pm @@ -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; } diff --git a/lib/sites/youtube.pm b/lib/sites/youtube.pm index 920c0d5..7f3d0c2 100644 --- a/lib/sites/youtube.pm +++ b/lib/sites/youtube.pm @@ -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; } -- GitLab