Created
March 6, 2015 04:12
-
-
Save yoku0825/f0708574294042cbf350 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use DBI; | |
use Text::MeCab; | |
my $parser= Text::MeCab->new(); | |
my $conn = DBI->connect("dbi:mysql:d1;mysql_socket=/usr/mysql/5.6.23/data/mysql.sock", | |
"root", "", {mysql_enable_utf8 => 1}); | |
my $rs = $conn->selectall_arrayref("SELECT tweet_id, text FROM tweets", {Slice =>{}}); | |
foreach my $row (@$rs) | |
{ | |
my @ret; | |
for (my $node= $parser->parse($row->{text}); $node; $node= $node->next) | |
{ | |
push(@ret, $node->surface) if $node->surface; | |
} | |
$conn->do("UPDATE tweets SET fts = ? WHERE tweet_id = ?", undef, join(" ", @ret), $row->{tweet_id}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment