MCPcopy Create free account
hub / github.com/bab2min/tomotopy / CTModelObject

Method CTModelObject

src/python/handler/py_CT.cpp:8–32  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6using namespace std;
7
8CTModelObject::CTModelObject(size_t tw, size_t minCnt, size_t minDf, size_t rmTop,
9 size_t k, PyObject* alpha, float eta,
10 PyObject* seed, PyObject* corpus, PyObject* transform)
11{
12 tomoto::CTArgs margs;
13 margs.k = k;
14 if (alpha) margs.alpha = broadcastObj<tomoto::Float>(alpha, margs.k,
15 [=]() { return "`smoothing_alpha` must be an instance of `float` or `List[float]` with length `k` (given " + py::repr(alpha) + ")"; }
16 );
17 margs.eta = eta;
18 if (seed && seed != Py_None && !py::toCpp<size_t>(seed, margs.seed))
19 {
20 throw py::ValueError{ "`seed` must be an integer or None." };
21 }
22
23 inst = tomoto::ICTModel::create((tomoto::TermWeight)tw, margs);
24 if (!inst) throw py::ValueError{ "unknown `tw` value" };
25 isPrepared = false;
26 seedGiven = !!seed;
27 minWordCnt = minCnt;
28 minWordDf = minDf;
29 removeTopWord = rmTop;
30
31 insertCorpus(corpus, transform);
32}
33
34py::UniqueObj CTModelObject::getCorrelations(PyObject* topicId) const
35{

Callers

nothing calls this directly

Calls 1

reprFunction · 0.85

Tested by

no test coverage detected