class Company::Mapping::TextDocument
A simple text document
Attributes
contents[RW]
id[RW]
tokenizer[RW]
Public Class Methods
new(id = SecureRandom.uuid, contents = "", tokenizer = BasicTokenizer.new)
click to toggle source
# File lib/company/mapping/document_utils/text_document.rb, line 7 def initialize(id = SecureRandom.uuid, contents = "", tokenizer = BasicTokenizer.new) @id, @contents, @tokenizer = id, contents, tokenizer end
Public Instance Methods
==(o)
click to toggle source
# File lib/company/mapping/document_utils/text_document.rb, line 21 def ==(o) o.class == self.class && o.state == self.state end
bag_of_words()
click to toggle source
# File lib/company/mapping/document_utils/text_document.rb, line 11 def bag_of_words @tf = TermFrequency.new(@tokenizer) @bag_of_words = @tf.calculate(@contents) @bag_of_words end
equal?(o)
click to toggle source
# File lib/company/mapping/document_utils/text_document.rb, line 17 def equal?(o) o.class == self.class && o.state == self.state end
to_s()
click to toggle source
# File lib/company/mapping/document_utils/text_document.rb, line 25 def to_s "TextDocument:{#{id},#{contents}}" end
Protected Instance Methods
state()
click to toggle source
# File lib/company/mapping/document_utils/text_document.rb, line 30 def state [@id] end