Class: Zenra

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

Constant Summary collapse

VERSION =
'0.1.0'
@@app_id =
ENV['YAHOO_APPID']

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeZenra

Returns a new instance of Zenra.

Raises:

  • (RuntimeError)


21
22
23
# File 'lib/zenra.rb', line 21

def initialize
  raise RuntimeError, 'Yahoo API was not given.' unless Zenra.app_id
end

Class Method Details

.app_idObject



13
14
15
# File 'lib/zenra.rb', line 13

def self.app_id
  @@app_id
end

.app_id=(app_id) ⇒ Object



17
18
19
# File 'lib/zenra.rb', line 17

def self.app_id= app_id
  @@app_id = app_id
end

Instance Method Details

#zenrize(sentence, opts = {}) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/zenra.rb', line 25

def zenrize sentence, opts = {}
  opts = { :pos => '動詞', :add => '全裸で' }.merge(opts)
  YahooApiDAService.new(Zenra.app_id, sentence).parsed_array.inject('') do |r, v|
    r += opts[:add] if v['POS'].eql? opts[:pos]
    r += v['Surface']
  end
end