SudachiPy
SudachiPy copied to clipboard
sudachipy/lattice.pyx:35:12: Assignment to const attribute 'connect_costs'
Hi, After building the latest codes from git (branch "develop"), I have the following issue:
$ python setup.py build_ext --inplace
running build_ext
skipping 'sudachipy/latticenode.c' Cython extension (up-to-date)
cythoning sudachipy/lattice.pyx to sudachipy/lattice.c
Error compiling Cython file:
------------------------------------------------------------
...
cdef LatticeNode bos_node = LatticeNode()
bos_params = grammar.get_bos_parameter()
bos_node.set_parameter(bos_params[0], bos_params[1], bos_params[2])
bos_node.is_connected_to_bos = True
self.end_lists.append([bos_node])
self.connect_costs = self.grammar._matrix_view
^
------------------------------------------------------------
sudachipy/lattice.pyx:35:12: Assignment to const attribute 'connect_costs'
Error compiling Cython file:
------------------------------------------------------------
...
__pyx_result = Lattice.__new__(__pyx_type)
if __pyx_state is not None:
__pyx_unpickle_Lattice__set_state(<Lattice> __pyx_result, __pyx_state)
return __pyx_result
cdef __pyx_unpickle_Lattice__set_state(Lattice __pyx_result, tuple __pyx_state):
__pyx_result.capacity = __pyx_state[0]; __pyx_result.connect_costs = __pyx_state[1]; __pyx_result.end_lists = __pyx_state[2]; __pyx_result.eos_node = __pyx_state[3]; __pyx_result.eos_params = __pyx_state[4]; __pyx_result.grammar = __pyx_state[5]; __pyx_result.size = __pyx_state[6]
^
------------------------------------------------------------
(tree fragment):10:56: Assignment to const attribute 'connect_costs'
building 'sudachipy.lattice' extension
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/user/python/include/python3.6m -c sudachipy/lattice.c -o build/temp.linux-x86_64-3.6/sudachipy/lattice.o
sudachipy/lattice.c:1:2: error: #error Do not use this file, it is the result of a failed Cython compilation.
#error Do not use this file, it is the result of a failed Cython compilation.
^~~~~
error: command 'gcc' failed with exit status 1
Can you show me how to tackle the above issue, please? Thanks advance for your help.
Then, I updated our file "./sudachipy/lattice.pxd" (remove "const" in line "cdef const short[:,:] connect_costs") as follows
from .latticenode cimport LatticeNode
cdef extern from "limits.h":
cdef int INT_MAX
cdef class Lattice:
cdef int size
cdef int capacity
cdef LatticeNode eos_node
cdef list end_lists
cdef object grammar
cdef object eos_params
# cdef const short[:,:] connect_costs
cdef short[:,:] connect_costs
cpdef void resize(self, int size)
cpdef void insert(self, int begin, int end, LatticeNode node)
cdef void connect_node(self, LatticeNode r_node)
cdef void connect_eos_node(self)
Then, building is okie as follows:
$ ../bin/python.sh setup.py build_ext --inplace
running build_ext
skipping 'sudachipy/latticenode.c' Cython extension (up-to-date)
cythoning sudachipy/lattice.pyx to sudachipy/lattice.c
building 'sudachipy.lattice' extension
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/user/python/include/python3.6m -c sudachipy/lattice.c -o build/temp.linux-x86_64-3.6/sudachipy/lattice.o
gcc -pthread -shared -L/home/konverso/dev/installer/kbot/3rdparty/zlib-1.2.11/lib -L/home/user/python/sqlite-autoconf-3170000/lib -L/home/user/python/bzip2-1.0.6/lib -L/home/user/python/openssl-1.0.2r/lib -L/usr/lib/x86_64-linux-gnu build/temp.linux-x86_64-3.6/sudachipy/lattice.o -L/home/user/python/lib -lpython3.6m -o build/lib.linux-x86_64-3.6/sudachipy/lattice.cpython-36m-x86_64-linux-gnu.so
cythoning sudachipy/tokenizer.pyx to sudachipy/tokenizer.c
building 'sudachipy.tokenizer' extension
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/home/user/python/include/python3.6m -c sudachipy/tokenizer.c -o build/temp.linux-x86_64-3.6/sudachipy/tokenizer.o
gcc -pthread -shared -L/home/user/python/zlib-1.2.11/lib -L/home/user/python/sqlite-autoconf-3170000/lib -L/home/user/python/bzip2-1.0.6/lib -L/home/user/python/openssl-1.0.2r/lib -L/usr/lib/x86_64-linux-gnu build/temp.linux-x86_64-3.6/sudachipy/tokenizer.o -L/home/user/python/lib -lpython3.6m -o build/lib.linux-x86_64-3.6/sudachipy/tokenizer.cpython-36m-x86_64-linux-gnu.so
copying build/lib.linux-x86_64-3.6/sudachipy/latticenode.cpython-36m-x86_64-linux-gnu.so -> sudachipy
copying build/lib.linux-x86_64-3.6/sudachipy/lattice.cpython-36m-x86_64-linux-gnu.so -> sudachipy
copying build/lib.linux-x86_64-3.6/sudachipy/tokenizer.cpython-36m-x86_64-linux-gnu.so -> sudachipy
Thank you. We don't have time right now, so we'll look into it later.