Class: Pebbles::Zenra
- Inherits:
-
Object
- Object
- Pebbles::Zenra
- Defined in:
- lib/pebbles/zenra.rb
Constant Summary collapse
- VERSION =
'0.1.1'- @@app_id =
ENV['YAHOO_APPID']
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Zenra
constructor
A new instance of Zenra.
- #zenrize(sentence, opts = {}) ⇒ Object
Constructor Details
#initialize ⇒ Zenra
Returns a new instance of Zenra.
22 23 24 |
# File 'lib/pebbles/zenra.rb', line 22 def initialize raise RuntimeError, 'Yahoo API was not given.' unless Zenra.app_id end |
Class Method Details
.app_id ⇒ Object
14 15 16 |
# File 'lib/pebbles/zenra.rb', line 14 def self.app_id @@app_id end |
.app_id=(app_id) ⇒ Object
18 19 20 |
# File 'lib/pebbles/zenra.rb', line 18 def self.app_id= app_id @@app_id = app_id end |
Instance Method Details
#zenrize(sentence, opts = {}) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/pebbles/zenra.rb', line 26 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 |