Class: FastText::Model

Inherits:
Object
  • Object
show all
Defined in:
lib/fasttext/model.rb

Direct Known Subclasses

Classifier, Vectorizer

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Model

Returns a new instance of Model.



3
4
5
# File 'lib/fasttext/model.rb', line 3

def initialize(**options)
  @options = options
end

Instance Method Details

#dimensionObject



7
8
9
# File 'lib/fasttext/model.rb', line 7

def dimension
  m.dimension
end

#quantized?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/fasttext/model.rb', line 11

def quantized?
  m.quantized?
end

#save_model(path) ⇒ Object



15
16
17
# File 'lib/fasttext/model.rb', line 15

def save_model(path)
  m.save_model(path)
end

#sentence_vector(text) ⇒ Object



32
33
34
# File 'lib/fasttext/model.rb', line 32

def sentence_vector(text)
  m.sentence_vector(prep_text(text))
end

#subword_id(subword) ⇒ Object



40
41
42
# File 'lib/fasttext/model.rb', line 40

def subword_id(subword)
  m.subword_id(subword)
end

#subwords(word) ⇒ Object



44
45
46
# File 'lib/fasttext/model.rb', line 44

def subwords(word)
  m.subwords(word)
end

#word_id(word) ⇒ Object



36
37
38
# File 'lib/fasttext/model.rb', line 36

def word_id(word)
  m.word_id(word)
end

#word_vector(word) ⇒ Object



28
29
30
# File 'lib/fasttext/model.rb', line 28

def word_vector(word)
  m.word_vector(word)
end

#words(include_freq: false) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/fasttext/model.rb', line 19

def words(include_freq: false)
  words, freqs = m.words
  if include_freq
    words.zip(freqs).to_h
  else
    words
  end
end