File size: 516 Bytes
456f698 246f918 456f698 246f918 456f698 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
from typing import Optional
from singletons import CC_DICT, CHID_SET
from verification.wiktionary_client import WiktionaryClient
def verify_idiom_exists(idiom: str, wiktionary_client: Optional[WiktionaryClient] = None) -> bool:
"""Verify idiom exists via CHID Datatset, CC-CEDICT, or optional Wiktionary client."""
if idiom in CHID_SET:
return True
if CC_DICT.get_definitions(idiom):
return True
client = wiktionary_client or WiktionaryClient()
return client.exists(idiom) |