Sha256: 087b5ff3abf4c7a44cef216425d3e067629f8630a8bd26a4cda5d9eabddc8838

Contents?: true

Size: 953 Bytes

Versions: 3

Compression:

Stored size: 953 Bytes

Contents

#include <LLDA.h>

#include <rice/Module.hpp>

#include "utils.h"

void init_llda(Rice::Module& m) {
  Rice::define_class_under<tomoto::ILLDAModel, tomoto::ILDAModel>(m, "LLDA")
    .define_singleton_method(
      "_new",
      *[](size_t tw, size_t k, tomoto::Float alpha, tomoto::Float eta, size_t seed) {
        tomoto::LDAArgs args;
        args.k = k;
        args.alpha = {alpha};
        args.eta = eta;
        if (seed >= 0) {
          args.seed = seed;
        }
        return tomoto::ILLDAModel::create((tomoto::TermWeight)tw, args);
      })
    .define_method(
      "_add_doc",
      *[](tomoto::ILLDAModel& 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(
      "topics_per_label",
      *[](tomoto::ILLDAModel& self) {
        return self.getNumTopicsPerLabel();
      });
}

Version data entries

3 entries across 3 versions & 1 rubygems

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