Sha256: e3c4aa420f517987f80eed0afca1504aa3037613489a97f4962ff00c8c7919e3

Contents?: true

Size: 1.97 KB

Versions: 35

Compression:

Stored size: 1.97 KB

Contents

#include <HLDA.h>

#include <rice/rice.hpp>

#include "utils.h"

void init_hlda(Rice::Module& m) {
  Rice::define_class_under<tomoto::IHLDAModel, tomoto::ILDAModel>(m, "HLDA")
    .define_singleton_function(
      "_new",
      [](size_t tw, size_t levelDepth, tomoto::Float alpha, tomoto::Float eta, tomoto::Float gamma, size_t seed) {
        tomoto::HLDAArgs args;
        args.k = levelDepth;
        args.alpha = {alpha};
        args.eta = eta;
        args.gamma = gamma;
        if (seed >= 0) {
          args.seed = seed;
        }
        return tomoto::IHLDAModel::create((tomoto::TermWeight)tw, args);
      }, Rice::Return().takeOwnership())
    .define_method(
      "alpha",
      [](tomoto::IHLDAModel& self) {
        Array res;
        for (size_t i = 0; i < self.getLevelDepth(); i++) {
          res.push(self.getAlpha(i));
        }
        return res;
      })
    .define_method(
      "_children_topics",
      [](tomoto::IHLDAModel& self, tomoto::Tid topic_id) {
        return self.getChildTopicId(topic_id);
      })
    .define_method(
      "depth",
      [](tomoto::IHLDAModel& self) {
        return self.getLevelDepth();
      })
    .define_method(
      "gamma",
      [](tomoto::IHLDAModel& self) {
        return self.getGamma();
      })
    .define_method(
      "_level",
      [](tomoto::IHLDAModel& self, tomoto::Tid topic_id) {
        return self.getLevelOfTopic(topic_id);
      })
    .define_method(
      "live_k",
      [](tomoto::IHLDAModel& self) {
        return self.getLiveK();
      })
    .define_method(
      "_live_topic?",
      [](tomoto::IHLDAModel& self, tomoto::Tid topic_id) {
        return self.isLiveTopic(topic_id);
      })
    .define_method(
      "_num_docs_of_topic",
      [](tomoto::IHLDAModel& self, tomoto::Tid topic_id) {
        return self.getNumDocsOfTopic(topic_id);
      })
    .define_method(
      "_parent_topic",
      [](tomoto::IHLDAModel& self, tomoto::Tid topic_id) {
        return self.getParentTopicId(topic_id);
      });
}

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
tomoto-0.5.1-x86_64-linux ext/tomoto/hlda.cpp
tomoto-0.5.1-x86_64-darwin ext/tomoto/hlda.cpp
tomoto-0.5.1-arm64-darwin ext/tomoto/hlda.cpp
tomoto-0.5.1-aarch64-linux ext/tomoto/hlda.cpp
tomoto-0.5.1 ext/tomoto/hlda.cpp
tomoto-0.5.0-x86_64-linux ext/tomoto/hlda.cpp
tomoto-0.5.0-x86_64-darwin ext/tomoto/hlda.cpp
tomoto-0.5.0-arm64-darwin ext/tomoto/hlda.cpp
tomoto-0.5.0-aarch64-linux ext/tomoto/hlda.cpp
tomoto-0.5.0 ext/tomoto/hlda.cpp
tomoto-0.4.1-x86_64-linux ext/tomoto/hlda.cpp
tomoto-0.4.1-x86_64-darwin ext/tomoto/hlda.cpp
tomoto-0.4.1-arm64-darwin ext/tomoto/hlda.cpp
tomoto-0.4.1-aarch64-linux ext/tomoto/hlda.cpp
tomoto-0.4.1 ext/tomoto/hlda.cpp
tomoto-0.4.0-x86_64-linux ext/tomoto/hlda.cpp
tomoto-0.4.0-x86_64-darwin ext/tomoto/hlda.cpp
tomoto-0.4.0-arm64-darwin ext/tomoto/hlda.cpp
tomoto-0.4.0-aarch64-linux ext/tomoto/hlda.cpp
tomoto-0.4.0 ext/tomoto/hlda.cpp