Class: Lda::TextDocument
- Defined in:
- lib/lda-ruby/document/text_document.rb
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
Attributes inherited from Document
#corpus, #counts, #length, #tokens, #total, #words
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(corpus, text) ⇒ TextDocument
constructor
A new instance of TextDocument.
- #text? ⇒ Boolean
Methods inherited from Document
#handle, #recompute, #tokenize
Constructor Details
#initialize(corpus, text) ⇒ TextDocument
Returns a new instance of TextDocument.
5 6 7 8 9 10 11 12 |
# File 'lib/lda-ruby/document/text_document.rb', line 5 def initialize(corpus, text) super(corpus) @filename = nil tokenize(text) @corpus.stopwords.each { |w| @tokens.delete(w) } build_from_tokens end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
3 4 5 |
# File 'lib/lda-ruby/document/text_document.rb', line 3 def filename @filename end |
Class Method Details
.build_from_file(corpus, filename) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/lda-ruby/document/text_document.rb', line 18 def self.build_from_file(corpus, filename) text = File.read(filename) document = new(corpus, text) document.instance_variable_set(:@filename, filename.dup.freeze) document end |
Instance Method Details
#text? ⇒ Boolean
14 15 16 |
# File 'lib/lda-ruby/document/text_document.rb', line 14 def text? true end |