From 8ef5c9b0e15c45b09a22fd89a4ed7b0e180a9d2b Mon Sep 17 00:00:00 2001 From: Victor Chahuneau Date: Sun, 2 Jun 2013 14:55:53 -0400 Subject: Possible fix for #13 - use IntList .len instead of len() which can return long - a bit of code cleanup - upgrade to Cython 0.19 --- python/src/sa/alignment.pxi | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'python/src/sa/alignment.pxi') diff --git a/python/src/sa/alignment.pxi b/python/src/sa/alignment.pxi index 842899ad..f66f0fbf 100644 --- a/python/src/sa/alignment.pxi +++ b/python/src/sa/alignment.pxi @@ -5,21 +5,23 @@ from libc.stdlib cimport malloc, realloc, free # We have the space for our corpus, so this is not a problem; # May need to revisit if things get really tight, though. +cdef int ALIGNMENT_CODE = 1 << 16 + cdef class Alignment: cdef IntList links cdef IntList sent_index cdef int link(self, int i, int j): """Integerizes an alignment link pair""" - return i*65536 + j + return i * ALIGNMENT_CODE + j def unlink(self, link): """De-integerizes an alignment link pair""" - return (link/65536, link%65536) + return (link / ALIGNMENT_CODE, link % ALIGNMENT_CODE) cdef _unlink(self, int link, int* f, int* e): - f[0] = link/65536 - e[0] = link%65536 + f[0] = link / ALIGNMENT_CODE + e[0] = link % ALIGNMENT_CODE def get_sent_links(self, int sent_id): cdef IntList sent_links -- cgit v1.2.3