From d0f4aea58d3b1f48c54aaaa366423c1f18263f21 Mon Sep 17 00:00:00 2001 From: Sochen Date: Sun, 15 Mar 2026 13:18:11 +0000 Subject: [PATCH] feat(frequency_lookup): add get_freq_data() for batch frequency access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Exposes the full word→rank dict for use by the upcoming sentence_difficulty module without requiring per-word lookups. Co-Authored-By: Claude Sonnet 4.6 --- frequency_lookup.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/frequency_lookup.py b/frequency_lookup.py index 8a0bc4e..b2bf7e5 100644 --- a/frequency_lookup.py +++ b/frequency_lookup.py @@ -74,6 +74,16 @@ def get_frequency_rank(word_no_nikkud: str) -> int | None: return _freq.get(clean) +def get_freq_data() -> dict[str, int]: + """Return the full frequency dict (word -> rank). + + Auto-loads from cache if not yet loaded. + """ + if not _freq: + load() + return _freq + + if __name__ == "__main__": logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s") load()