Class: Markovian::Corpus
- Inherits:
-
Object
- Object
- Markovian::Corpus
- Defined in:
- lib/markovian/corpus.rb,
lib/markovian/corpus/chain.rb,
lib/markovian/corpus/compiler.rb,
lib/markovian/corpus/dictionary.rb,
lib/markovian/corpus/dictionary_entry.rb
Defined Under Namespace
Classes: Chain, Compiler, Dictionary, DictionaryEntry
Instance Attribute Summary collapse
-
#backward ⇒ Object
readonly
Returns the value of attribute backward.
-
#forward ⇒ Object
readonly
Returns the value of attribute forward.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize ⇒ Corpus
constructor
A new instance of Corpus.
- #next_word(word, previous_word: nil) ⇒ Object
- #previous_word(word, following_word: nil) ⇒ Object
- #random_word ⇒ Object
Constructor Details
Instance Attribute Details
#backward ⇒ Object (readonly)
Returns the value of attribute backward.
8 9 10 |
# File 'lib/markovian/corpus.rb', line 8 def backward @backward end |
#forward ⇒ Object (readonly)
Returns the value of attribute forward.
8 9 10 |
# File 'lib/markovian/corpus.rb', line 8 def forward @forward end |
Instance Method Details
#==(other) ⇒ Object
26 27 28 29 |
# File 'lib/markovian/corpus.rb', line 26 def ==(other) self.forward == other.forward && self.backward == other.backward end |
#next_word(word, previous_word: nil) ⇒ Object
13 14 15 |
# File 'lib/markovian/corpus.rb', line 13 def next_word(word, previous_word: nil) forward.next_word(word, previous_word: previous_word) end |
#previous_word(word, following_word: nil) ⇒ Object
17 18 19 20 |
# File 'lib/markovian/corpus.rb', line 17 def previous_word(word, following_word: nil) # backward goes in the opposite direction to forward backward.next_word(word, previous_word: following_word) end |
#random_word ⇒ Object
22 23 24 |
# File 'lib/markovian/corpus.rb', line 22 def random_word forward.random_word end |