From d69f7a7c1a9b5f6d29a7f28cdb7551829651ccc0 Mon Sep 17 00:00:00 2001 From: lukaszszpak <alukasz1@interia.pl> Date: Thu, 23 Nov 2023 09:30:11 +0100 Subject: [PATCH] feat: change default model to nc --- plwn/config.ini | 2 +- plwn/download.py | 44 ++++++-------------------------------------- setup.py | 2 +- 3 files changed, 8 insertions(+), 40 deletions(-) diff --git a/plwn/config.ini b/plwn/config.ini index 23a2ffb..70f43ff 100644 --- a/plwn/config.ini +++ b/plwn/config.ini @@ -1,2 +1,2 @@ [DOWNLOAD] -default_model = https://minio.clarin-pl.eu/public/models/plwn_api_dumps/plwn_dump_new_07-12-2022.sqlite +default_model = https://nc.clarin.e-science.pl/index.php/s/3p3exndFdqpnRGM diff --git a/plwn/download.py b/plwn/download.py index 9fac08a..7a6c42f 100644 --- a/plwn/download.py +++ b/plwn/download.py @@ -7,48 +7,16 @@ import requests from six.moves.urllib.request import urlopen from six.moves import configparser - config = configparser.ConfigParser() config_path = os.path.join(os.path.dirname( os.path.abspath(__file__)), "config.ini") config.read(config_path) -def get_available_models(): - """Returns available models.""" - root = ET.parse(urlopen("https://minio.clarin-pl.eu/public")).getroot() - available_models = [] - for child in root.findall( - "{http://s3.amazonaws.com/doc/2006-03-01/}Contents"): - if "models/plwn_api_dumps/" in str( - child.find( - "{http://s3.amazonaws.com/doc/2006-03-01/}Key").text): - string = child.find( - "{http://s3.amazonaws.com/doc/2006-03-01/}Key").text - substring = r"models/plwn_api_dumps/" - available_models.append(re.sub(substring, r'', string)) - return available_models - - def download(name="default_model"): - """After called it downloads a specified database model.""" - models = get_available_models() - if name == "default_model": - url = config["DOWNLOAD"][name] - r = requests.get(url) - with open(name, "wb") as f: - f.write(r.content) - f.close() - return - if name in models: - url = config["DOWNLOAD"]["default_model"] - url = url.replace("plwn_dump_new_07-12-2022.sqlite", name) - r = requests.get(url) - with open(name, "wb") as f: - f.write(r.content) - f.close() - else: - print("Cannot download: ", - name, - "\n Possible download options: ", - models) + url = config["DOWNLOAD"] + r = requests.get(url) + with open(name, "wb") as f: + f.write(r.content) + f.close() + return diff --git a/setup.py b/setup.py index fa88272..4bb4912 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ ENVNAME_DIST_NODEFAULT = 'PLWN_API_DIST_NO_DEFAULT_STORAGE' setup_args = dict( name='plwn_api_uuid', - version='0.1', + version='0.11', license='LGPL-3.0+', description='Python API to access plWordNet lexicon', -- GitLab