Skip to content

Commit ae3f849

Browse files
authored
Merge pull request #1388 from phoneee/fix/wsd-trie-ordering
fix: build WSD Trie after populating dictionary, not before
2 parents b113e0b + 223393d commit ae3f849

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

pythainlp/wsd/core.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@
1212
_wsd_dict: dict[str, Union[list[str], list[list[str]]]] = thai_wsd_dict()
1313
_mean_all: dict[str, list[str]] = {}
1414

15-
_all_word: set[str] = cast("set[str]", set(_mean_all.keys()))
16-
_TRIE: Trie = Trie(_all_word)
17-
_word_cut: Tokenizer = Tokenizer(custom_dict=_TRIE)
18-
1915
words: list[str] = cast("list[str]", _wsd_dict["word"])
2016
meanings: list[list[str]] = cast("list[list[str]]", _wsd_dict["meaning"])
2117
i_word: str
2218
i_meanings: list[str]
2319
for i_word, i_meanings in zip(words, meanings):
2420
_mean_all[i_word] = i_meanings
2521

22+
_all_word: set[str] = cast("set[str]", set(_mean_all.keys()))
23+
_TRIE: Trie = Trie(_all_word)
24+
_word_cut: Tokenizer = Tokenizer(custom_dict=_TRIE)
25+
2626
_MODEL_CACHE: dict[str, _SentenceTransformersModel] = {}
2727

2828

0 commit comments

Comments
 (0)