From 182768c7adab1c0f2a5e44d4c133d6674f2abec1 Mon Sep 17 00:00:00 2001 From: Sveinbjorn Thordarson Date: Wed, 28 Aug 2024 16:42:30 +0000 Subject: [PATCH] Fixes as per code review --- src/icegrams/ngrams.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/icegrams/ngrams.py b/src/icegrams/ngrams.py index 29303d8..6f8614a 100644 --- a/src/icegrams/ngrams.py +++ b/src/icegrams/ngrams.py @@ -143,7 +143,7 @@ # Import the CFFI wrapper for the trie.cpp C++ module # (see also trie.py and build_trie.py) -elif __name__ == "__main__": +if __name__ == "__main__": # Running as a main program from _trie import lib as trie_cffi, ffi # type: ignore # pylint: disable=import-error from trie import Trie @@ -157,7 +157,7 @@ # unpacked and ready for use import importlib.resources as importlib_resources - ref = importlib_resources.files("icegrams").joinpath("resources/trigrams.bin") + ref = importlib_resources.files("icegrams").joinpath("resources", "trigrams.bin") BINARY_FILENAME = str(ref) ffi: Any = cast(Any, ffi) # type: ignore @@ -865,8 +865,8 @@ def bigram_frequency(self, i0: Optional[int], i1: Optional[int]) -> int: if i0 is None or i1 is None: return 0 # Check degenerate case - # if not (i0 or i1): - # return 0 + if not (i0 or i1): + return 0 assert self._unigram_ptrs_ml is not None p1, p2 = self._unigram_ptrs_ml.lookup_pair(i0) # Then, look for id i1 within the level 2 ids delimited by [p1, p2>