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

Method PAModelObject

src/python/handler/py_PA.cpp:8–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6using namespace std;
7
8PAModelObject::PAModelObject(size_t tw, size_t minCnt, size_t minDf, size_t rmTop,
9 size_t k1, size_t k2,
10 PyObject* alpha, PyObject* subAlpha, float eta,
11 PyObject* seed, PyObject* corpus, PyObject* transform)
12{
13 tomoto::PAArgs margs;
14 margs.k = k1;
15 margs.k2 = k2;
16 if (alpha)
17 {
18 margs.alpha = broadcastObj<tomoto::Float>(alpha, k1,
19 [&]() { return "`alpha` must be an instance of `float` or `List[float]` with length `k1` (given " + py::repr(alpha) + ")"; }
20 );
21 }
22 if (subAlpha)
23 {
24 margs.subalpha = broadcastObj<tomoto::Float>(subAlpha, k2,
25 [=]() { return "`subalpha` must be an instance of `float` or `List[float]` with length `k2` (given " + py::repr(subAlpha) + ")"; }
26 );
27 }
28 margs.eta = eta;
29
30 if (seed && seed != Py_None && !py::toCpp<size_t>(seed, margs.seed))
31 {
32 throw py::ValueError{ "`seed` must be an integer or None." };
33 }
34
35 auto inst = tomoto::IPAModel::create((tomoto::TermWeight)tw, margs);
36 if (!inst) throw py::ValueError{ "unknown `tw` value" };
37 this->inst = move(inst);
38 this->isPrepared = false;
39 this->seedGiven = !!seed;
40 this->minWordCnt = minCnt;
41 this->minWordDf = minDf;
42 this->removeTopWord = rmTop;
43
44 insertCorpus(corpus, transform);
45}
46
47std::vector<float> PAModelObject::getSubTopicPrior(size_t topicId, bool normalize) const
48{

Callers

nothing calls this directly

Calls 1

reprFunction · 0.85

Tested by

no test coverage detected