def download(language, show_progress=True): model_types = { "analyser": "analyser-gt-desc.hfstol", "analyser-norm": "analyser-gt-norm.hfstol", "analyser-dict": "analyser-dict-gt-norm.hfstol", "generator-desc": "generator-gt-desc.hfstol", "generator-norm": "generator-gt-norm.hfstol", "generator": "generator-dict-gt-norm.hfstol", "cg": "disambiguator.bin", "metadata.json": "metadata.json", "dictionary.json": "dictionary.json" } download_to = os.path.join(__find_writable_folder(__model_base_folders()), language) ssl._create_default_https_context = ssl._create_unverified_context if not os.path.exists(download_to): os.makedirs(download_to) for model_type, model_url in model_types.items(): try: print("Downloading " + model_type + " for " + language) url = download_server_url + language + "/" + model_url save_to = os.path.join(download_to, model_type) mikatools.download_file(url, save_to, show_progress) print("Model " + model_type + " for " + language + " was downloaded") except: if model_type == "metadata.json": mikatools.json_dump({"info": "no metadata provided"}, save_to) print( "Couldn't download " + model_type + " for " + language + ". It might be that the model for the language is not supported yet." )
def download(lang,show_progress=True): urls = mikatools.download_json(semfi_urls) if lang not in urls: raise "Language not supported. Currently supported languages " + ", ".join(urls.keys()) download_to = os.path.join(__find_writable_folder(__model_base_folders()), lang) if not os.path.exists(download_to): os.makedirs(download_to) save_to = os.path.join(download_to, "sem.db") print("Downloading: "+ lang) mikatools.download_file(urls[lang], save_to, show_progress)
def download(language, show_progress=True): model_types = [ "analyser", "analyser-norm", "generator-desc", "generator-norm", "generator", "cg", "metadata.json" ] download_to = os.path.join(__find_writable_folder(__model_base_folders()), language) ssl._create_default_https_context = ssl._create_unverified_context if not os.path.exists(download_to): os.makedirs(download_to) for model_type in model_types: try: print("Downloading " + model_type + " for " + language) url = api_url + "downloadModel/?language=" + language + "&type=" + model_type save_to = os.path.join(download_to, model_type) mikatools.download_file(url, save_to, show_progress) print("Model " + model_type + " for " + language + " was downloaded") except: print( "Couldn't download " + model_type + " for " + language + ". It might be that the model for the language is not supported yet." )