Skip to content
Browse files

Improve MeCab::Node add each by mecab-modern

  • Loading branch information...
1 parent fbf95e1 commit d1df2186f217b618b1b592980744192c318556d1 @myokoym committed Oct 7, 2012
Showing with 6 additions and 5 deletions.
  1. +4 −5 lib/mecab-syllable/syllable.rb
  2. +2 −0 mecab-syllable.gemspec
View
9 lib/mecab-syllable/syllable.rb
@@ -1,6 +1,7 @@
# encoding: utf-8
require 'MeCab'
+require 'mecab-modern'
module MeCab
class Node
@@ -25,19 +26,17 @@ def count
private
def split(text)
mecab = MeCab::Tagger.new
- node = mecab.parseToNode(text)
+ nodes = mecab.parseToNode(text)
syllables = []
- while node
+ nodes.each do |node|
part = node.part
- unless part.empty?
+ next if part.empty?
kana = node.kana
if kana
syllables << select_syllable(kana)
else
syllables << select_syllable(part)
end
- end
- node = node.next
end
syllables
end
View
2 mecab-syllable.gemspec
@@ -18,4 +18,6 @@ Gem::Specification.new do |gem|
gem.require_paths = ["lib"]
gem.required_ruby_version = '>= 1.9.1'
+
+ gem.add_runtime_dependency 'mecab-modern', ['>= 0.0.2']
end

0 comments on commit d1df218

Please sign in to comment.
Something went wrong with that request. Please try again.