You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PaddleSpeech/third_party/python-pinyin/phrase-pinyin-data/get_latest_cc_cedict.py

27 lines
572 B

# -*- coding: utf-8 -*-
import os
import io
import shutil
import codecs
import zipfile
import requests
ROOT = os.path.dirname(os.path.realpath(__file__))
if __name__ == '__main__':
DOWNLOAD_URL = 'https://cc-cedict.org/editor/editor_export_cedict.php?c=zip'
zip_file_path = os.path.join(ROOT, 'cc-cedict.zip')
with open(zip_file_path, 'wb') as f:
response = requests.get(DOWNLOAD_URL, stream=True)
shutil.copyfileobj(response.raw, f)
with open(zip_file_path, 'rb') as fp:
z = zipfile.ZipFile(fp)
z.extractall(ROOT)