-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactoring file location. Added tar files extraction
- Loading branch information
Showing
3 changed files
with
32 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,45 @@ | ||
from os.path import join | ||
import os | ||
import tarfile | ||
from arekit.contrib.source import utils | ||
from network.args.const import EMBEDDING_FILEPATH, SYNONYMS_FILEPATH, BERT_PRETRAINED_MODEL_PATH, \ | ||
BERT_FINETUNED_MODEL_PATH | ||
|
||
from examples.args import const | ||
|
||
|
||
def download_examples_data(): | ||
root_dir = utils.get_default_download_dir() | ||
|
||
data = { | ||
EMBEDDING_FILEPATH: "http://rusvectores.org/static/models/rusvectores2/news_mystem_skipgram_1000_20_2015.bin.gz", | ||
SYNONYMS_FILEPATH: "https://raw.githubusercontent.com/nicolay-r/RuSentRel/v1.1/synonyms.txt", | ||
const.EMBEDDING_FILEPATH: "http://rusvectores.org/static/models/rusvectores2/news_mystem_skipgram_1000_20_2015.bin.gz", | ||
const.SYNONYMS_FILEPATH: "https://raw.githubusercontent.com/nicolay-r/RuSentRel/v1.1/synonyms.txt", | ||
# NOTE: this is a pre-trained model and it is expected to be fine-tunned. | ||
BERT_PRETRAINED_MODEL_PATH: "https://www.dropbox.com/s/cr6nejxjiqbyd5o/ra-20-srubert-large-neut-nli-pretrained-3l.tar.gz?dl=1", | ||
const.BERT_PRETRAINED_MODEL_PATHDIR: "https://www.dropbox.com/s/cr6nejxjiqbyd5o/ra-20-srubert-large-neut-nli-pretrained-3l.tar.gz?dl=1", | ||
# Fine-tuned on RuSentRel collection. | ||
BERT_FINETUNED_MODEL_PATH: "https://www.dropbox.com/s/g73osmwyrqtr2at/ra-20-srubert-large-neut-nli-pretrained-3l-finetuned.tar.gz?dl=1" | ||
|
||
const.BERT_FINETUNED_MODEL_PATHDIR: "https://www.dropbox.com/s/g73osmwyrqtr2at/ra-20-srubert-large-neut-nli-pretrained-3l-finetuned.tar.gz?dl=1" | ||
} | ||
|
||
untar = [ | ||
const.BERT_PRETRAINED_MODEL_PATHDIR, | ||
const.BERT_FINETUNED_MODEL_PATHDIR | ||
] | ||
|
||
# Perform downloading ... | ||
for local_name, url_link in data.items(): | ||
print("Downloading: {}".format(local_name)) | ||
utils.download(dest_file_path=join(root_dir, local_name), | ||
utils.download(dest_file_path=os.path.join(root_dir, local_name), | ||
source_url=url_link) | ||
|
||
# Extracting tar files ... | ||
for local_name in untar: | ||
local_name += '.tar.gz' | ||
print(local_name) | ||
if not os.path.exists(local_name): | ||
continue | ||
if not tarfile.is_tarfile(local_name): | ||
continue | ||
with tarfile.open(local_name) as f: | ||
target = os.path.dirname(local_name) | ||
f.extractall(path=target) | ||
|
||
|
||
if __name__ == '__main__': | ||
download_examples_data() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.