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

Method getScore

src/python/handler/py_coherence.cpp:37–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37double CoherenceObject::getScore(PyObject* words) const
38{
39 vector<tomoto::Vid> wordIds;
40 py::foreach<string>(words, [&](const string& w)
41 {
42 auto wid = corpus->getVocabDict().toWid(w);
43 if (wid != tomoto::non_vocab_id) wordIds.emplace_back(wid);
44 }, "`words` must be an iterable of `str`.");
45
46 switch (seg)
47 {
48 case Segmentation::one_one:
49 return model.template getScore<Segmentation::one_one>(cm, wordIds.begin(), wordIds.end());
50 case Segmentation::one_pre:
51 return model.template getScore<Segmentation::one_pre>(cm, wordIds.begin(), wordIds.end());
52 case Segmentation::one_suc:
53 return model.template getScore<Segmentation::one_suc>(cm, wordIds.begin(), wordIds.end());
54 case Segmentation::one_all:
55 return model.template getScore<Segmentation::one_all>(cm, wordIds.begin(), wordIds.end());
56 case Segmentation::one_set:
57 return model.template getScore<Segmentation::one_set>(cm, wordIds.begin(), wordIds.end());
58 default:
59 throw py::ValueError{ "invalid Segmentation `seg`" };
60 }
61}
62
63void addCoherenceTypes(py::Module& module)
64{

Callers

nothing calls this directly

Calls 4

toWidMethod · 0.80
emplace_backMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected