Sha256: 95084b228bdf14a9abb774f7c84fd6b249c50cd19c0bf46e99f0de09adaaa2d6

Contents?: true

Size: 904 Bytes

Versions: 2

Compression:

Stored size: 904 Bytes

Contents

# ext
require "fasttext/ext"

# stdlib
require "tempfile"

# modules
require_relative "fasttext/model"
require_relative "fasttext/classifier"
require_relative "fasttext/vectorizer"
require_relative "fasttext/version"

module FastText
  class Error < StandardError; end

  class << self
    def load_model(path)
      m = Ext::Model.new
      m.load_model(path)
      model =
        if m.supervised?
          FastText::Classifier.new
        else
          FastText::Vectorizer.new
        end
      model.instance_variable_set("@m", m)
      model
    end

    def train_supervised(**options)
      input = options.delete(:input)
      model = FastText::Classifier.new(**options)
      model.fit(input)
      model
    end

    def train_unsupervised(**options)
      input = options.delete(:input)
      model = FastText::Vectorizer.new(**options)
      model.fit(input)
      model
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fasttext-0.4.0 lib/fasttext.rb
fasttext-0.3.0 lib/fasttext.rb