Class: Kuromoji::Commands

Inherits:
Thor
  • Object
show all
Defined in:
lib/kuromoji/commands.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = [], options = {}, config = {}) ⇒ Commands

Returns a new instance of Commands.



13
14
15
16
17
# File 'lib/kuromoji/commands.rb', line 13

def initialize(args = [], options = {}, config = {})
  super(args, options, config)
  @global_options = config[:shell].base.options
  @core = Kuromoji::Core.new(@global_options[:user_dictionary])
end

Instance Method Details

#all_featuresObject



26
27
28
29
# File 'lib/kuromoji/commands.rb', line 26

def all_features
  sentence = STDIN.read
  puts Yajl::Encoder.encode(@core.tokenize(sentence))
end

#readingObject



32
33
34
35
# File 'lib/kuromoji/commands.rb', line 32

def reading
  sentence = STDIN.read
  puts Yajl::Encoder.encode(@core.reading(sentence))
end

#tokenizeObject



20
21
22
23
# File 'lib/kuromoji/commands.rb', line 20

def tokenize
  sentence = STDIN.read
  puts Yajl::Encoder.encode(@core.tokenize_with_hash(sentence))
end