Skip to content

Commit

Permalink
fixed compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
bab2min committed Jul 31, 2024
1 parent 2a76f34 commit 712a8c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/python/dispatcher/py_rt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include <Python.h>
#endif

using namespace std;

#if defined(_WIN32) || defined(_WIN64)
#include <Windows.h>
#include <immintrin.h>
Expand All @@ -41,6 +39,8 @@ void cpuid(int info[4], int InfoType) {

PyMODINIT_FUNC PyInit__tomotopy()
{
using namespace std;

bool sse2 = false, avx = false, avx2 = false;
bool env_sse2 = false, env_avx = false, env_avx2 = false;

Expand Down
12 changes: 6 additions & 6 deletions src/python/handler/py_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ PyObject* CorpusObject::addDoc(CorpusObject* self, PyObject* args, PyObject* kwa
{
doc.words.emplace_back(self->vocab->vocabs->add(PyUnicode_AsUTF8(t)));
}
else if (Py_IsNone(t))
else if (t == Py_None)
{
doc.words.emplace_back(tomoto::non_vocab_id);
}
Expand All @@ -395,15 +395,15 @@ PyObject* CorpusObject::addDoc(CorpusObject* self, PyObject* args, PyObject* kwa
PyObject* word = PyTuple_GetItem(t, 0);
PyObject* pos = PyTuple_GetItem(t, 1);
PyObject* len = PyTuple_GetItem(t, 2);
if (!((PyUnicode_Check(word) || Py_IsNone(word)) && PyLong_Check(pos) && PyLong_Check(len))) throw py::ValueError{ "`tokenizer` must return an iterable of `str` or `tuple` of (`str`, `int`, `int`)." };
if (!((PyUnicode_Check(word) || word == Py_None) && PyLong_Check(pos) && PyLong_Check(len))) throw py::ValueError{ "`tokenizer` must return an iterable of `str` or `tuple` of (`str`, `int`, `int`)." };
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);
}
else if (Py_IsNone(word))
else if (word == Py_None)
{
isStopword = true;
}
Expand Down Expand Up @@ -491,7 +491,7 @@ PyObject* CorpusObject::addDocs(CorpusObject* self, PyObject* args, PyObject* kw
{
doc.words.emplace_back(self->vocab->vocabs->add(PyUnicode_AsUTF8(t)));
}
else if (Py_IsNone(t))
else if (t == Py_None)
{
doc.words.emplace_back(tomoto::non_vocab_id);
}
Expand All @@ -500,7 +500,7 @@ PyObject* CorpusObject::addDocs(CorpusObject* self, PyObject* args, PyObject* kw
PyObject* word = PyTuple_GetItem(t, 0);
PyObject* pos = PyTuple_GetItem(t, 1);
PyObject* len = PyTuple_GetItem(t, 2);
if (!((PyUnicode_Check(word) || Py_IsNone(word)) && PyLong_Check(pos) && PyLong_Check(len))) throw py::ValueError{ "`tokenizer` must return an iterable of `str` or `tuple` of (`str`, `int`, `int`)." };
if (!((PyUnicode_Check(word) || word == Py_None) && PyLong_Check(pos) && PyLong_Check(len))) throw py::ValueError{ "`tokenizer` must return an iterable of `str` or `tuple` of (`str`, `int`, `int`)." };

bool isStopword = false;
if (stopwords != Py_None)
Expand All @@ -509,7 +509,7 @@ PyObject* CorpusObject::addDocs(CorpusObject* self, PyObject* args, PyObject* kw
if (!stopRet) throw py::ExcPropagation{};
isStopword = PyObject_IsTrue(stopRet);
}
else if (Py_IsNone(word))
else if (word == Py_None)
{
isStopword = true;
}
Expand Down

0 comments on commit 712a8c0

Please sign in to comment.