dict_dl/d.py

34 lines
1.1 KiB
Python
Raw Normal View History

2022-11-15 11:41:33 +00:00
#!/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():
2023-09-05 14:00:29 +00:00
print(k, v)
2022-11-15 11:41:33 +00:00
# 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)