From c58aaf3076ee1ccf7c7ecad9e75f031250d68c81 Mon Sep 17 00:00:00 2001 From: Dafne van Kuppevelt Date: Mon, 11 Jan 2021 13:39:13 +0100 Subject: [PATCH] download function in python module #5 --- setup.sh | 12 ------------ stroll/util.py | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 12 deletions(-) delete mode 100755 setup.sh create mode 100644 stroll/util.py diff --git a/setup.sh b/setup.sh deleted file mode 100755 index ad01516..0000000 --- a/setup.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash -mkdir -p models - -# Download srl model -if [ ! -f models/srl.pt ]; then - wget https://surfdrive.surf.nl/files/index.php/s/kOgUm0oEpmx5HiZ/download -O models/srl.pt -fi - -# Download word vectors -if [ ! -f models/fasttext.model.bin ]; then - wget https://surfdrive.surf.nl/files/index.php/s/085yxFcRmn0osMw/download -O models/fasttext.model.bin -fi diff --git a/stroll/util.py b/stroll/util.py new file mode 100644 index 0000000..521d562 --- /dev/null +++ b/stroll/util.py @@ -0,0 +1,16 @@ +from pathlib import Path +import urllib.request + + +def download_srl_model(datapath): + datapath = Path(datapath) + fname_fasttext = datapath / 'fasttext.model.bin' + fname_model = datapath / 'srl.pt' + if not fname_fasttext.exists(): + url = 'https://surfdrive.surf.nl/files/index.php/s/085yxFcRmn0osMw/download' + urllib.request.urlretrieve(url, fname_fasttext) + + if not fname_model.exists(): + url = 'https://surfdrive.surf.nl/files/index.php/s/kOgUm0oEpmx5HiZ/download' + urllib.request.urlretrieve(url, fname_model) + return fname_fasttext, fname_model