Skip to content

Instantly share code, notes, and snippets.

@nipotan
Created January 22, 2016 10:24
Show Gist options
  • Select an option

  • Save nipotan/e2412eecfdbbf71ca1e5 to your computer and use it in GitHub Desktop.

Select an option

Save nipotan/e2412eecfdbbf71ca1e5 to your computer and use it in GitHub Desktop.
modified to handle the first mecab node rightly for Acme::Lou
--- Lou.pm.orig 2007-02-01 19:08:45.000000000 +0900
+++ Lou.pm 2016-01-22 19:18:52.144838848 +0900
@@ -116,7 +116,7 @@
$text = encode($self->{mecab_charset}, $text);
my @out;
my $node = $self->mecab->parse($text);
- while ($node = $node->next) {
+ while ($node) {
my $n = $self->decode_node($node);
$n->{to} = $self->dic($n->{original});
@@ -151,6 +151,7 @@
} else {
push @out, $n->{surface};
}
+ $node = $node->next;
}
$text = join "", @out;
$text =~ s/\r/\n/g;
@tomill
Copy link
Copy Markdown

tomill commented Jan 22, 2016

OK!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment