#!/bin/python import os import sys from dict_dl import DictFile if len(sys.argv) < 2: query = next(sys.stdin).strip() else: query = sys.argv[1].strip() prefix = query[:3] d = DictFile(os.path.expandvars(f"$DICT_DL/en_MerriamWebster/{prefix}_MW.json")) print(f"||||||||{query}||||||||") for k, v in d[query].items(): print(k, v) # if k != "type": # table = Table(title=k) # table.add_column("synonyms", justify="center", style="cyan", no_wrap=True) # table.add_column("near synonyms", justify="center", style="cyan", no_wrap=True) # table.add_column("near antonyms", justify="center", style="cyan", no_wrap=True) # table.add_column("antonyms", justify="center", style="cyan", no_wrap=True) # syns = v["synonyms"] # nsyns = v["related" if "related" in v else "near synonyms"] # ants = v["near antonyms"] # nants = v["antonyms"] # for s, ns, na, a in zip_longest(syns, nsyns, nants, ants, fillvalue=""): # table.add_row(s, ns, na, a) # console = Console() # console.print(table)