| from recommend import train_and_save_itemcf |
| MODEL_URL = "https://dl.fbaipublicfiles.com/fasttext/vectors-crawl/cc.zh.300.bin.gz" |
| MODEL_PATH = os.path.join(MODEL_DIR, "cc.zh.300.bin") |
| COMPRESSED_PATH = MODEL_PATH + ".gz" |
| if not os.path.exists(MODEL_DIR): |
| if os.path.exists(MODEL_PATH): |
| print("⏬ 下载 fastText 中文模型...") |
| urllib.request.urlretrieve(MODEL_URL, COMPRESSED_PATH) |
| with gzip.open(COMPRESSED_PATH, 'rb') as f_in: |
| with open(MODEL_PATH, 'wb') as f_out: |
| shutil.copyfileobj(f_in, f_out) |
| os.remove(COMPRESSED_PATH) |
| if __name__ == "__main__": |