Class: RubyFastText::WordVectors
- Inherits:
-
Object
- Object
- RubyFastText::WordVectors
- Defined in:
- lib/ruby_fast_text/word_vectors.rb
Instance Attribute Summary collapse
-
#vectors ⇒ Object
Returns the value of attribute vectors.
Instance Method Summary collapse
- #get_vector(word) ⇒ Object
-
#initialize(params) ⇒ WordVectors
constructor
A new instance of WordVectors.
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
#vectors ⇒ Object
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 |