Class: Semantic::MatrixTransformer
- Inherits:
-
Object
- Object
- Semantic::MatrixTransformer
- Defined in:
- lib/semantic/matrix_transformer.rb
Instance Method Summary collapse
- #apply_transforms(vector_space_model) ⇒ Object
-
#initialize(options = {}) ⇒ MatrixTransformer
constructor
A new instance of MatrixTransformer.
Constructor Details
#initialize(options = {}) ⇒ MatrixTransformer
Returns a new instance of MatrixTransformer.
4 5 6 7 |
# File 'lib/semantic/matrix_transformer.rb', line 4 def initialize(={}) @transforms = [:transforms] || [:TFIDF, :LSA] @options = end |
Instance Method Details
#apply_transforms(vector_space_model) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/semantic/matrix_transformer.rb', line 9 def apply_transforms(vector_space_model) @transforms.each do |transform| begin transform_class = Semantic::Transform.const_get(transform) Semantic.logger.info("Applying #{transform} transform") vector_space_model.matrix = transform_class.send(:transform, vector_space_model.matrix) if transform_class.respond_to?(:transform) Semantic.logger.info(vector_space_model) rescue Exception => e Semantic.logger.error("Error: Cannot perform transform: #{transform}") Semantic.logger.error(e) end end vector_space_model end |