Sha256: d43f9a48dbfea0c026df734be31cce160b735500ba109584e2f72405645fb5be

Contents?: true

Size: 988 Bytes

Versions: 3

Compression:

Stored size: 988 Bytes

Contents

#include <PLDA.h>

#include <rice/Module.hpp>

#include "utils.h"

void init_plda(Rice::Module& m) {
  Rice::define_class_under<tomoto::IPLDAModel, tomoto::ILLDAModel>(m, "PLDA")
    .define_singleton_method(
      "_new",
      *[](size_t tw, size_t latent_topics, tomoto::Float alpha, tomoto::Float eta, size_t seed) {
        tomoto::PLDAArgs args;
        args.numLatentTopics = latent_topics;
        args.alpha = {alpha};
        args.eta = eta;
        if (seed >= 0) {
          args.seed = seed;
        }
        return tomoto::IPLDAModel::create((tomoto::TermWeight)tw, args);
      })
    .define_method(
      "_add_doc",
      *[](tomoto::IPLDAModel& self, std::vector<std::string> words, std::vector<std::string> labels) {
        auto doc = buildDoc(words);
        doc.misc["labels"] = labels;
        return self.addDoc(doc);
      })
    .define_method(
      "latent_topics",
      *[](tomoto::IPLDAModel& self) {
        return self.getNumLatentTopics();
      });
}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tomoto-0.2.2 ext/tomoto/plda.cpp
tomoto-0.2.1 ext/tomoto/plda.cpp
tomoto-0.2.0 ext/tomoto/plda.cpp