From 294c16c110b22b9f16de174cdaaf10cac3adde1f Mon Sep 17 00:00:00 2001 From: surtur Date: Thu, 16 Dec 2021 05:06:13 +0100 Subject: [PATCH] chore: add base of pick_ngrams() method --- da_detector.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/da_detector.py b/da_detector.py index 2e93a5a..2e9860c 100755 --- a/da_detector.py +++ b/da_detector.py @@ -45,9 +45,23 @@ class da_detector: raise e return obj + def pick_ngrams(self, what_grams: int, text: str): + if not isinstance(what_grams, int): + raise TypeError("what_grams has to be an int") + + self.what_grams = what_grams + + if (what_grams <= 0): + raise ValueError("this is bogus, give me a number from ℕ") + elif (what_grams > 5): + raise ValueError("not doing larger-grams than 5") + + # TODO(me): complete n-gram picking method implementation + freqs_folder = "./freqs/" detector = da_detector() +detector.pick_ngrams(3, "") sk_json = detector.parse_freqs("sk.json") cz_json = detector.parse_freqs("cz.json")