Class: Basset::DocumentOverrideExample

Inherits:
Document
  • Object
show all
Defined in:
lib/basset/document_override_example.rb

Overview

This class is an example for how to do custom document representations. In this example, I change the way text is cleaned and don’t stem the words. It would also be easy to put in additional hard coded features. The important thing to note is that the new document class only needs one function: vector_of_features

Instance Attribute Summary

Attributes inherited from Document

#classification, #text

Instance Method Summary collapse

Methods inherited from Document

#feature_vectors, #initialize

Constructor Details

This class inherits a constructor from Basset::Document

Instance Method Details

#vector_of_featuresObject



7
8
9
# File 'lib/basset/document_override_example.rb', line 7

def vector_of_features
  @vector_of_features ||= vector_of_features_from_terms_hash( terms_hash_from_words_array( text.gsub(/\W/, ' ').split(' ') ) )
end