Sha256: f5eaba2ae9f5c028d40549e9be9126c8e791f34cd151164736d8f1f26a48a6bb
Contents?: true
Size: 1.27 KB
Versions: 4
Compression:
Stored size: 1.27 KB
Contents
#!/usr/bin/env ruby # coding: utf-8 require 'thor' require 'yajl' module Kuromoji class Commands < Thor map '-a' => :all_features map '-r' => :reading map '-t' => :tokenize class_option :user_dictionary, type: :string, aliases: '-d', default: nil, desc: 'disp downcase' def initialize(args = [], options = {}, config = {}) super(args, options, config) @global_options = config[:shell].base.options @core = Kuromoji::Core.new(@global_options[:user_dictionary]) end desc 'tokenize', "echo '関西国際空港は、大阪府大阪市の南西38kmにまたがる会社管理空港である' | kuromoji -t" def tokenize sentence = STDIN.read puts Yajl::Encoder.encode(@core.tokenize_with_hash(sentence)) end desc 'all_features', "echo '関西国際空港は、大阪府大阪市の南西38kmにまたがる会社管理空港である' | kuromoji -a" def all_features sentence = STDIN.read puts Yajl::Encoder.encode(@core.tokenize(sentence)) end desc 'reading', "echo '関西国際空港は、大阪府大阪市の南西38kmにまたがる会社管理空港である' | kuromoji -r " def reading sentence = STDIN.read puts Yajl::Encoder.encode(@core.reading(sentence)) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
kuromoji-ruby-0.0.4 | lib/kuromoji/commands.rb |
kuromoji-ruby-0.0.3 | lib/kuromoji/commands.rb |
kuromoji-ruby-0.0.2 | lib/kuromoji/commands.rb |
kuromoji-ruby-0.0.1 | lib/kuromoji/commands.rb |