Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PLWN_API
Manage
Activity
Members
Labels
Plan
Issues
10
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Libraries
PLWN_API
Commits
1408fe0d
There was an error fetching the commit references. Please try again later.
Commit
1408fe0d
authored
4 years ago
by
leszeks
Browse files
Options
Downloads
Patches
Plain Diff
merge request changes
parent
7d897cab
1 merge request
!4
Adding download option
Pipeline
#1046
failed with stage
in 38 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
README.md
+12
-0
12 additions, 0 deletions
README.md
plwn/__init__.py
+2
-0
2 additions, 0 deletions
plwn/__init__.py
plwn/config.ini
+1
-1
1 addition, 1 deletion
plwn/config.ini
plwn/download.py
+34
-9
34 additions, 9 deletions
plwn/download.py
setup.py
+1
-1
1 addition, 1 deletion
setup.py
with
50 additions
and
11 deletions
README.md
+
12
−
0
View file @
1408fe0d
...
@@ -69,6 +69,18 @@ To load this version at a later date, use `plwn.load(path)` instead of `plwn.loa
...
@@ -69,6 +69,18 @@ To load this version at a later date, use `plwn.load(path)` instead of `plwn.loa
>>> api = plwn.load("storage-dumps/plwn-new.db")
>>> api = plwn.load("storage-dumps/plwn-new.db")
Downloading API dumps
=====================
In order to download one of the dumps available at https://minio.clarin-pl.eu/ :
import plwn
plwn.download("optional_name")
File will be downloaded to the current directory.
If optional_name is not provided default dump will be downloaded.
If optional_name is provided but doesn't match name of any available dumps, the process will fail
and display possible names.
Licenses
Licenses
========
========
...
...
This diff is collapsed.
Click to expand it.
plwn/__init__.py
+
2
−
0
View file @
1408fe0d
...
@@ -20,6 +20,7 @@ from ._loading import read
...
@@ -20,6 +20,7 @@ from ._loading import read
from
._loading
import
load
from
._loading
import
load
from
._loading
import
show_source_formats
from
._loading
import
show_source_formats
from
._loading
import
show_storage_formats
from
._loading
import
show_storage_formats
from
.download
import
download
# Import the enums that are needed for selecting and filtering
# Import the enums that are needed for selecting and filtering
from
.enums
import
PoS
,
RelationKind
from
.enums
import
PoS
,
RelationKind
...
@@ -35,4 +36,5 @@ __all__ = [
...
@@ -35,4 +36,5 @@ __all__ = [
"
show_source_formats
"
,
"
show_source_formats
"
,
"
load_default
"
,
"
load_default
"
,
"
RelationKind
"
,
"
RelationKind
"
,
"
download
"
,
]
]
This diff is collapsed.
Click to expand it.
plwn/config.ini
+
1
−
1
View file @
1408fe0d
[DOWNLOAD]
[DOWNLOAD]
model
=
https://minio.clarin-pl.eu/public/models/plwn_api_dumps/plwn_dump_27-03-2018.sqlite
default_model
=
https://minio.clarin-pl.eu/public/models/plwn_api_dumps/plwn_dump_27-03-2018.sqlite
\ No newline at end of file
\ No newline at end of file
This diff is collapsed.
Click to expand it.
plwn/download.py
+
34
−
9
View file @
1408fe0d
"""
Implementation of download method.
"""
"""
Implementation of download method.
"""
import
configparser
import
configparser
import
os
import
os
import
xml.etree.ElementTree
as
ET
import
re
import
requests
import
requests
from
six.moves.urllib.request
import
urlopen
models
=
{
"
model
"
,
}
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
():
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
):
def
download
(
name
=
"
default_model
"
):
"""
After called it downloads a specified database model.
"""
After called it downloads a specified database model.
Currently only one model available.
Currently only one model available.
"""
"""
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
:
if
name
in
models
:
cfg
=
configparser
.
ConfigParser
()
url
=
config
[
"
DOWNLOAD
"
][
"
default_model
"
]
config_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
url
=
url
.
replace
(
"
plwn_dump_27-03-2018.sqlite
"
,
name
)
os
.
path
.
abspath
(
__file__
)),
"
config.ini
"
)
cfg
.
read
(
config_path
)
url
=
cfg
[
"
DOWNLOAD
"
][
name
]
r
=
requests
.
get
(
url
)
r
=
requests
.
get
(
url
)
with
open
(
name
,
"
wb
"
)
as
f
:
with
open
(
name
,
"
wb
"
)
as
f
:
f
.
write
(
r
.
content
)
f
.
write
(
r
.
content
)
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
1408fe0d
...
@@ -9,7 +9,7 @@ ENVNAME_DIST_NODEFAULT = 'PLWN_API_DIST_NO_DEFAULT_STORAGE'
...
@@ -9,7 +9,7 @@ ENVNAME_DIST_NODEFAULT = 'PLWN_API_DIST_NO_DEFAULT_STORAGE'
setup_args
=
dict
(
setup_args
=
dict
(
name
=
'
PLWN_API
'
,
name
=
'
PLWN_API
'
,
version
=
'
0.2
3
'
,
version
=
'
0.2
4
'
,
license
=
'
LGPL-3.0+
'
,
license
=
'
LGPL-3.0+
'
,
description
=
'
Python API to access plWordNet lexicon
'
,
description
=
'
Python API to access plWordNet lexicon
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment