Class: DuckPunching
- Inherits:
-
Object
- Object
- DuckPunching
- Defined in:
- lib/duck_punching.rb,
lib/duck_punching/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize ⇒ DuckPunching
constructor
A new instance of DuckPunching.
- #random_noun ⇒ Object
- #random_participle ⇒ Object
Constructor Details
#initialize ⇒ DuckPunching
Returns a new instance of DuckPunching.
6 7 8 9 10 11 12 |
# File 'lib/duck_punching.rb', line 6 def initialize Linguistics.use(:en) @lexicon = WordNet::Lexicon.new # use wordnet-defaultdb @num_nouns = WordNet::Synset.nouns.count @num_verbs = WordNet::Synset.verbs.count end |
Instance Method Details
#call ⇒ Object
25 26 27 |
# File 'lib/duck_punching.rb', line 25 def call "#{random_noun} #{random_participle}" end |
#random_noun ⇒ Object
14 15 16 17 |
# File 'lib/duck_punching.rb', line 14 def random_noun synset = WordNet::Synset.nouns.limit(1, rand(@num_nouns)).first synset.words.sample.lemma end |
#random_participle ⇒ Object
19 20 21 22 23 |
# File 'lib/duck_punching.rb', line 19 def random_participle synset = WordNet::Synset.verbs.limit(1, rand(@num_verbs)).first word = synset.words.sample.lemma word.en.present_participle end |