class CachedDictionaryLookup:
"""Cached wrapper for dictionary lookups.
Caches syllable/word validation and frequency lookups.
"""
def __init__(
self,
provider: DictionaryLookup,
syllable_cache_size: int = 4096,
word_cache_size: int = 8192,
use_lock: bool = False,
):
self._provider = provider
# Creates instance-specific lru_cache methods for:
# is_valid_syllable, is_valid_word,
# get_syllable_frequency, get_word_frequency
def is_valid_syllable(self, syllable: str) -> bool:
"""Check if syllable exists in dictionary (cached)."""
...
def is_valid_word(self, word: str) -> bool:
"""Check if word exists in dictionary (cached)."""
...
def get_syllable_frequency(self, syllable: str) -> int:
"""Get syllable frequency (cached)."""
...
def get_word_frequency(self, word: str) -> int:
"""Get word frequency (cached)."""
...