### Home Classes Methods

### In Files

- lib/plugins/hatena_keyword_haiku.rb

### Namespace

- CLASS HatenaKeywordHaiku::Word

### Methods

- ::generate
- ::setup
- ::words

### Files

- ChangeLog
- README.rdoc

### Class/Module Index

Quicksearch

- Termtter
- Termtter::API
- Termtter::ActiveRubytter
- Termtter::Client
- Termtter::Client::DirectMessage
- Termtter::Client::Jakigan
- Termtter::Client::SearchEvent
- Termtter::Client::UserSearchEvent
- Termtter::Command
- Termtter::CommandCanceled
- Termtter::CommandLine
- Termtter::CommandNotFound
- Termtter::Config
- Termtter::ConfigSetup
- Termtter::Crypt
- Termtter::English
- Termtter::Event
- Termtter::HTTPpool
- Termtter::Hook
- Termtter::HookCanceled
- Termtter::Hookable
- Termtter::JSONError
- Termtter::MemoryCache
- Termtter::MemoryCache::MemCacheMock
- Termtter::OptParser
- Termtter::Plugin
- Termtter::Plugin::Screen
- Termtter::Plugins
- Termtter::Plugins::Haml
- Termtter::Plugins::ListSwitch
- Termtter::RubytterProxy
- Termtter::RubytterProxy::FrequentAccessError
- Termtter::RubytterProxy::LimitManager
- Termtter::Status
- Termtter::StdOut
- Termtter::Storage
- Termtter::Storage::SQLite3
- Termtter::Storage::Status
- Termtter::Task
- Termtter::TaskManager
- Termtter::TypableIdGenerator
- Termtter::UserStreamReceiver
- Yharian
- Yharian::Alex
- Yharian::Jenifer
- Yharian::Remark
- Yharian::Speaker
- Yharian::Vicki
- Yharian::Yhara
- HatenaKeywordHaiku
- HatenaKeywordHaiku::Word
- OAuth
- OAuth::AccessToken
- Readline
- Readline::LIBREADLINE
- AAMaker
- Array
- BrowserNotFound
- Growl
- IRB
- Object
- Status
- String
- Symbol
- TermColor
- TermtterIrcGateway
- User

No matching classes.

# HatenaKeywordHaiku

### Public Class Methods

generate(*args) click to toggle source

    # File lib/plugins/hatena_keyword_haiku.rb, line 27
    def self.generate(*args)
      args  = [5,7,5] if args.empty?

      args.map{ |len|
        words[len.to_i].choice rescue raise "No word which length is #{len}"
      }.map{ |w| w.word }.join(' ')
    end

setup(csv_path = '/tmp/keywordlist_furigana.csv', csv_url = 'http://d.hatena.ne.jp/images/keyword/keywordlist_furigana.csv') click to toggle source

d.hatena.ne.jp/hatenadiary/20060922/1158908401

    # File lib/plugins/hatena_keyword_haiku.rb, line 36
    def self.setup(csv_path = '/tmp/keywordlist_furigana.csv', csv_url = 'http://d.hatena.ne.jp/images/keyword/keywordlist_furigana.csv')
      return if @@words
      @@words = { }
      csv_path = File.expand_path(csv_path)
      unless File.exists? csv_path
        puts "haiku: downloading CSV"
        open(csv_path, 'w'){ |f|
          f.write(open(csv_url).read)
        }
      end

      puts "haiku: parsing CSV"
      open(csv_path).each_line{ |line|
        yomi, word = *NKF.nkf('-w', line.chomp).split(/\t/)
        next unless yomi and word
        w = Word.new(word, yomi)
        @@words[w.length] = [] unless @@words.has_key? w.length
        @@words[w.length].push w
      }
      puts "haiku: setup done"
      @@words
    end

words() click to toggle source

    # File lib/plugins/hatena_keyword_haiku.rb, line 60
    def self.words
      setup unless @@words
      @@words
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.