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

Method load

src/python/handler/py_utils.cpp:1258–1273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1256}
1257
1258py::UniqueCObj<PhraserObject> PhraserObject::load(PyObject* cls, const std::string& path)
1259{
1260 if (!cls) cls = (PyObject*)py::Type<PhraserObject>;
1261 else if (!PyObject_IsSubclass(cls, (PyObject*)py::Type<PhraserObject>)) throw runtime_error{ "`cls` must be a derived class of `Phraser`." };
1262
1263 ifstream ifs{ path };
1264 if (!ifs) throw py::OSError{ string{"cannot read from '"} + path + "'" };
1265 py::UniqueCObj<PhraserObject> ret{ (PhraserObject*)PyObject_CallObject(cls, nullptr) };
1266 if (!ret) throw py::ExcPropagation{};
1267 tomoto::serializer::readMany(ifs, tomoto::serializer::to_keyz("tph1"),
1268 ret->vocabs,
1269 ret->cand_info,
1270 ret->trie_nodes
1271 );
1272 return ret;
1273}
1274
1275void addUtilsTypes(py::Module& module)
1276{

Callers

nothing calls this directly

Calls 2

readManyFunction · 0.85
to_keyzFunction · 0.85

Tested by

no test coverage detected