Class: RubyFastText::NN
- Inherits:
-
Object
- Object
- RubyFastText::NN
- Defined in:
- lib/ruby_fast_text/nn.rb
Instance Attribute Summary collapse
-
#k ⇒ Object
readonly
Returns the value of attribute k.
-
#predictor ⇒ Object
Returns the value of attribute predictor.
Instance Method Summary collapse
-
#initialize(params) ⇒ NN
constructor
A new instance of NN.
-
#neighbours(word) ⇒ Object
TODO: Fix, only getting one line out of the result.
Constructor Details
#initialize(params) ⇒ NN
Returns a new instance of NN.
6 7 8 9 10 11 12 13 14 |
# File 'lib/ruby_fast_text/nn.rb', line 6 def initialize(params) path = params[:path] model = params[:model] @k = params.fetch(:k, 10) @predictor = Dir.chdir(path) do IO.popen("fasttext nn #{model} #{k}", 'r+') end end |
Instance Attribute Details
#k ⇒ Object (readonly)
Returns the value of attribute k.
4 5 6 |
# File 'lib/ruby_fast_text/nn.rb', line 4 def k @k end |
#predictor ⇒ Object
Returns the value of attribute predictor.
3 4 5 |
# File 'lib/ruby_fast_text/nn.rb', line 3 def predictor @predictor end |
Instance Method Details
#neighbours(word) ⇒ Object
TODO: Fix, only getting one line out of the result
17 18 19 20 |
# File 'lib/ruby_fast_text/nn.rb', line 17 def neighbours(word) predictor.puts(word) format_result(read_lines) end |