Skip to content

Commit

Permalink
fixed stopwords test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bab2min committed Dec 18, 2023
1 parent 07d4a36 commit d584a21
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/python/py_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,14 @@ PyObject* CorpusObject::addDoc(CorpusObject* self, PyObject* args, PyObject* kwa
if (!PyObject_IsTrue(words)) return py::buildPyValue(-1);
py::foreach<string>(words, [&](const string& w)
{
py::UniqueObj stopRet{ PyObject_CallObject(stopwords, py::UniqueObj{ py::buildPyTuple(w) }) };
if (!stopRet) throw py::ExcPropagation{};
doc.words.emplace_back(PyObject_IsTrue(stopRet) ? -1 : self->vocab->vocabs->add(w));
bool isStopword = false;
if (stopwords != Py_None)
{
py::UniqueObj stopRet{ PyObject_CallObject(stopwords, py::UniqueObj{ py::buildPyTuple(word) }) };
if (!stopRet) throw py::ExcPropagation{};
isStopword = PyObject_IsTrue(stopRet);
}
doc.words.emplace_back(isStopword ? -1 : self->vocab->vocabs->add(w));
}, "");
}
PyObject* key, * value;
Expand Down

0 comments on commit d584a21

Please sign in to comment.