Class: Okura::Console

Inherits:
Object
  • Object
show all
Defined in:
lib/okura/console.rb

Instance Method Summary collapse

Instance Method Details

#run_console(dict_dir) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/okura/console.rb', line 6

def run_console dict_dir
  tagger=Okura::Serializer::FormatInfo.create_tagger(dict_dir)
  print 'okura> '
  while $stdin.gets
	nodes=tagger.parse($_.strip)
	(0...nodes.length).each{|i|
	  puts nodes[i].map{|n|"#{n.word.surface}\t#{n.word.right.text} #{n.word.cost}"}
	  puts
	}
	nodes.mincost_path.each{|n|
	  puts "#{n.word.surface}\t#{n.word.right.text}"
	}
	print 'okura> '
  end
  return 0
end