Skip to content
This repository has been archived by the owner on Mar 9, 2023. It is now read-only.

Commit

Permalink
Merge pull request #158 from yokomotod/slow-user-dic-build
Browse files Browse the repository at this point in the history
  • Loading branch information
katsutan committed Aug 16, 2021
2 parents 468e0bf + fd4561c commit 9eae063
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions sudachipy/dictionarylib/doublearraylexicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,22 @@ def size(self) -> int:
return self.word_params.size

def get_word_id(self, headword: str, pos_id: int, reading_form: str) -> int:
for wid, _ in self.lookup(headword.encode('utf-8'), 0):
if self._compare_word_id(wid, headword, pos_id, reading_form):
return wid

for wid in range(self.word_infos.size()):
info = self.word_infos.get_word_info(wid)
if info.surface == headword \
and info.pos_id == pos_id \
and info.reading_form == reading_form:
if self._compare_word_id(wid, headword, pos_id, reading_form):
return wid

return -1

def _compare_word_id(self, wid: int, headword: str, pos_id: int, reading_form: str) -> bool:
info = self.word_infos.get_word_info(wid)
return info.surface == headword \
and info.pos_id == pos_id \
and info.reading_form == reading_form

def get_dictionary_id(self, word_id: int) -> int:
return 0

Expand Down

0 comments on commit 9eae063

Please sign in to comment.