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

Method getTopics

src/python/handler/py_utils.cpp:952–965  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

950}
951
952std::vector<std::pair<tomoto::Tid, tomoto::Float>> DocumentObject::getTopics(size_t topN, bool fromPseudoDoc) const
953{
954 if (corpus->isIndependent()) throw py::RuntimeError{ "This method can only be called by documents bound to the topic model." };
955 if (!corpus->tm->inst) throw py::RuntimeError{ "inst is null" };
956 if (!corpus->tm->isPrepared) throw py::RuntimeError{ "train() should be called first for calculating the topic distribution" };
957
958 if (owner && !initialized)
959 {
960 if (PyErr_WarnEx(PyExc_RuntimeWarning, "This document has no topic information. Call `infer()` method passing this document as an argument first!", 1)) throw py::ExcPropagation{};
961 }
962
963 if (fromPseudoDoc) return getTopicsFromPseudoDoc(topN);
964 return corpus->tm->inst->getTopicsByDocSorted(getBoundDoc(), topN);
965}
966
967std::vector<float> DocumentObject::getTopicDist(bool normalize, bool fromPseudoDoc) const
968{

Callers

nothing calls this directly

Calls 2

isIndependentMethod · 0.80
getTopicsByDocSortedMethod · 0.80

Tested by

no test coverage detected