Class: Semantic::VectorSpace::Model
- Inherits:
-
Linalg::DMatrix
- Object
- Linalg::DMatrix
- Semantic::VectorSpace::Model
- Defined in:
- lib/semantic/vector_space/model.rb
Instance Method Summary collapse
-
#initialize(matrix, keywords) ⇒ Model
constructor
A new instance of Model.
- #matrix ⇒ Object
- #matrix=(matrix) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(matrix, keywords) ⇒ Model
Returns a new instance of Model.
9 10 11 12 |
# File 'lib/semantic/vector_space/model.rb', line 9 def initialize(matrix, keywords) @keywords = keywords || {} super(matrix) end |
Instance Method Details
#matrix ⇒ Object
18 19 20 |
# File 'lib/semantic/vector_space/model.rb', line 18 def matrix @_dc_obj end |
#matrix=(matrix) ⇒ Object
14 15 16 |
# File 'lib/semantic/vector_space/model.rb', line 14 def matrix=(matrix) @_dc_obj = matrix end |
#to_s ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/semantic/vector_space/model.rb', line 22 def to_s out = StringIO.new out.print " " * 9 matrix.ncol.times do |id| out.print " D#{id+1} " end out.puts matrix.rows.each_with_index do |terms, index| out.print "#{@keywords.index(index).ljust(6)}" if @keywords.has_value?(index) out.print "[ " terms.columns.each do |document| out.print "%+0.2f " % document end out.print "]" out.puts end out.string end |