Created
May 24, 2016 14:06
-
-
Save rummelonp/9c03b9562d68f9eb2630752861f26e5d 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
module Natto | |
Node = Struct.new(:surface, :part, :part_sub1, :part_sub2, :part_sub3, :conjugation1, :conjugation2, :original, :read, :pron) | |
class MeCab | |
def parse_to_node(text) | |
nodes = parse(text).split("\n").map(&:strip) | |
nodes = nodes.map do |node| | |
next if node == 'EOS' | |
surface, feature = *node.split("\t") | |
Node.new(surface, *feature.split(',')) | |
end | |
nodes.compact | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment