Class: HiwaiKaeuta

Inherits:
Object
  • Object
show all
Defined in:
lib/hiwai_kaeuta.rb,
lib/hiwai_kaeuta/subst.rb,
lib/hiwai_kaeuta/inference.rb,
lib/hiwai_kaeuta/subst_set.rb

Defined Under Namespace

Modules: Mecab Classes: Inference, PriorityQueue, Subst, SubstSet

Class Method Summary collapse

Class Method Details

.convert(text) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/hiwai_kaeuta.rb', line 2

def self.convert(text)
  nodes = Mecab::Nodes.new(text)
  strs = converted_strings(nodes)
  ''.tap do |res|
    location = 0
    nodes.each_with_index do |node, node_index|
      str_index = text.index(node.surface, location)
      res << text[location...str_index]
      res << strs[node_index]
      location = str_index + node.surface.length
    end
  end
end