Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cython build error and expose three more methods #33

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/dawg.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ cdef class DAWG:
cpdef bint b_has_key(self, bytes key) except -1:
return self.dct.Contains(key, len(key))

cpdef bytes tobytes(self):
cpdef bytes tobytes(self) except +:
"""
Return raw DAWG content as bytes.
"""
Expand Down Expand Up @@ -176,6 +176,17 @@ cdef class DAWG:

def _file_size(self):
return self.dct.file_size()

cpdef BaseType root(self):
return self.dct.root()

cpdef (bint, BaseType) follow(self, unicode label, BaseType index):
cdef bytes _label = <bytes>label.encode('utf8')
rs = self.dct.Follow(_label, &index)
return rs, index

def has_value(self, index: BaseType) -> bool:
return self._has_value(index)

cdef bint _has_value(self, BaseType index):
return self.dct.has_value(index)
Expand Down