Class: ChainPunk::Corpus
- Inherits:
-
Object
- Object
- ChainPunk::Corpus
- Defined in:
- lib/chain_punk/corpus.rb
Instance Attribute Summary collapse
-
#frequency_table ⇒ Object
readonly
Returns the value of attribute frequency_table.
-
#seeds ⇒ Object
readonly
Returns the value of attribute seeds.
Instance Method Summary collapse
-
#initialize(text, options = {}) ⇒ Corpus
constructor
A new instance of Corpus.
- #train(text, options = {}) ⇒ Object
Constructor Details
#initialize(text, options = {}) ⇒ Corpus
Returns a new instance of Corpus.
7 8 9 |
# File 'lib/chain_punk/corpus.rb', line 7 def initialize(text, = {}) train(text, ) end |
Instance Attribute Details
#frequency_table ⇒ Object (readonly)
Returns the value of attribute frequency_table.
5 6 7 |
# File 'lib/chain_punk/corpus.rb', line 5 def frequency_table @frequency_table end |
#seeds ⇒ Object (readonly)
Returns the value of attribute seeds.
5 6 7 |
# File 'lib/chain_punk/corpus.rb', line 5 def seeds @seeds end |
Instance Method Details
#train(text, options = {}) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/chain_punk/corpus.rb', line 11 def train(text, = {}) exclusion_text = remove_exclusions(text, [:exclusions]) text_phrases = process_sets(exclusion_text, [:closures]) grapheme_phrases = process_phrases(text_phrases, [:boundaries]) @frequency_table, @seeds = process_graphemes(grapheme_phrases, [:index_size]) end |