Class: Langue::Japanese::Parser
- Inherits:
-
Object
- Object
- Langue::Japanese::Parser
- Includes:
- Logging
- Defined in:
- lib/langue/japanese/parser.rb
Instance Attribute Summary collapse
-
#mecab_options ⇒ Object
Returns the value of attribute mecab_options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Parser
constructor
A new instance of Parser.
- #parse(text) ⇒ Object
Methods included from Logging
Constructor Details
#initialize(options = {}) ⇒ Parser
Returns a new instance of Parser.
12 13 14 15 16 |
# File 'lib/langue/japanese/parser.rb', line 12 def initialize( = {}) = [:mecab_options] || {} @logger = [:logger] || null_logger @taggers = {} end |
Instance Attribute Details
#mecab_options ⇒ Object
Returns the value of attribute mecab_options.
18 19 20 |
# File 'lib/langue/japanese/parser.rb', line 18 def end |
Instance Method Details
#parse(text) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/langue/japanese/parser.rb', line 20 def parse(text) morphemes = Morphemes.new node = tagger.parseToNode(text) while node surface = node.surface.force_encoding('utf-8') unless surface.empty? feature = node.feature.force_encoding('utf-8') morphemes << create_morpheme(surface, feature) end node = node.next end morphemes end |