Class: RubyFastText::WordVectors

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_fast_text/word_vectors.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ WordVectors

Returns a new instance of WordVectors.



5
6
7
8
9
10
11
# File 'lib/ruby_fast_text/word_vectors.rb', line 5

def initialize(params)
  path = params[:path]
  model = params[:model]
  @vectors = Dir.chdir(path) do
    IO.popen("fasttext print-word-vectors #{model}", 'r+')
  end
end

Instance Attribute Details

#vectorsObject

Returns the value of attribute vectors.



3
4
5
# File 'lib/ruby_fast_text/word_vectors.rb', line 3

def vectors
  @vectors
end

Instance Method Details

#get_vector(word) ⇒ Object



13
14
15
16
# File 'lib/ruby_fast_text/word_vectors.rb', line 13

def get_vector(word)
  vectors.puts(word)
  format_result(vectors.gets)
end