diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2012-07-25 23:40:06 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2012-07-25 23:40:06 -0400 |
commit | acae00bbe2c2d43bf0606cd7cc268d93179e077f (patch) | |
tree | ec2a7281247b960cc9bf3ccd9fbbe3eb17c724b4 /sa-extract | |
parent | 070e7fbbacd70dd916a95c1ab08b0113ec221c30 (diff) |
maybe faster
Diffstat (limited to 'sa-extract')
-rw-r--r-- | sa-extract/Makefile | 2 | ||||
-rw-r--r-- | sa-extract/csuf.pxd | 5 | ||||
-rw-r--r-- | sa-extract/csuf.pyx | 7 |
3 files changed, 8 insertions, 6 deletions
diff --git a/sa-extract/Makefile b/sa-extract/Makefile index 3145bbfe..10d14521 100644 --- a/sa-extract/Makefile +++ b/sa-extract/Makefile @@ -1,5 +1,5 @@ %.c: %.pyx - cython $< -o $@ + cython -X cdivision=True $< -o $@ %.o: %.cc g++ -O6 -g -fPIC -c $< diff --git a/sa-extract/csuf.pxd b/sa-extract/csuf.pxd index f44167dd..972f0178 100644 --- a/sa-extract/csuf.pxd +++ b/sa-extract/csuf.pxd @@ -5,7 +5,8 @@ cdef class SuffixArray: cdef cdat.DataArray darray cdef cintlist.CIntList sa cdef cintlist.CIntList ha + # cdef lookup(self, word, int offset, int low, int high) cdef __lookup_helper(self, int word_id, int offset, int low, int high) cdef __get_range(self, int word_id, int offset, int low, int high, int midpoint) - cdef __search_low(self, int word_id, int offset, int low, int high) - cdef __search_high(self, word_id, offset, low, high) + cdef int __search_low(self, int word_id, int offset, int low, int high) + cdef int __search_high(self, int word_id, int offset, int low, int high) diff --git a/sa-extract/csuf.pyx b/sa-extract/csuf.pyx index 64c44788..2f0b1383 100644 --- a/sa-extract/csuf.pyx +++ b/sa-extract/csuf.pyx @@ -223,7 +223,7 @@ cdef class SuffixArray: f.close() - cdef __search_high(self, word_id, offset, low, high): + cdef int __search_high(self, int word_id, int offset, int low, int high): cdef int midpoint if low >= high: @@ -235,7 +235,7 @@ cdef class SuffixArray: return self.__search_high(word_id, offset, low, midpoint) - cdef __search_low(self, int word_id, int offset, int low, int high): + cdef int __search_low(self, int word_id, int offset, int low, int high): cdef int midpoint if low >= high: @@ -269,7 +269,8 @@ cdef class SuffixArray: return self.__lookup_helper(word_id, offset, midpoint+1, high) - def lookup(self, word, offset, int low, int high): + def lookup(self, word, int offset, int low, int high): + cdef int wordid if low == -1: low = 0 if high == -1: |