Skip to content

Commit c472cf5

Browse files
authored
Merge pull request #48 from gbv/rvk
Update RVK processing (#24)
2 parents 4d818b4 + e17cdbf commit c472cf5

File tree

6 files changed

+25
-21
lines changed

6 files changed

+25
-21
lines changed

README.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ URIs can be also be generated on the fly from an URI template specified with opt
9191
is to use 010 or 016 if defined, otherwise 001. If you find examples where this approach
9292
fails, please add them to [#42](https://github.com/scriptotek/mc2skos/issues/42).
9393
* ``{collection}`` is "class", "table" or "scheme"
94-
* ``{object}`` is a member of the classification scheme (with spaces replaced by
95-
hyphens) and part of a ``{collection}``, such as a specific class or table.
94+
* ``{object}`` is a member of the classification scheme and part of a ``{collection}``, such
95+
as a specific class or table. Spaces in the URI are replaced by hyphens or another character
96+
configured with option `--whitespace`.
9697
* ``{edition}`` is taken from ``084 $c`` (with language code stripped)
9798

9899

examples/rvk.ttl

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,29 @@
88
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
99
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
1010

11-
# RVK has no official URIs yet. Use example.org for testing
12-
13-
<http://example.org/rvk/A> a skos:Concept ;
11+
<http://rvk.uni-regensburg.de/nt/A> a skos:Concept ;
1412
dcterms:created "2012-07-05"^^xsd:date ;
1513
dcterms:identifier "1:" ;
1614
dcterms:modified "2017-09-12"^^xsd:date ;
1715
skos:notation "A" ;
1816
skos:prefLabel "Allgemeines"@de ;
19-
skos:topConceptOf <http://example.org/rvk> .
17+
skos:topConceptOf <http://rvk.uni-regensburg.de/nt/> .
2018

21-
<http://example.org/rvk/AA> a skos:Concept ;
19+
<http://rvk.uni-regensburg.de/nt/AA> a skos:Concept ;
2220
dcterms:created "2012-07-05"^^xsd:date ;
2321
dcterms:identifier "2:" ;
2422
dcterms:modified "2017-09-12"^^xsd:date ;
25-
skos:broader <http://example.org/rvk/A> ;
26-
skos:inScheme <http://example.org/rvk> ;
23+
skos:broader <http://rvk.uni-regensburg.de/nt/A> ;
24+
skos:inScheme <http://rvk.uni-regensburg.de/nt/> ;
2725
skos:notation "AA" ;
2826
skos:prefLabel "Bibliographien der Bibliographien, Universalbibliographien, Bibliothekskataloge, Nationalbibliographien"@de .
2927

30-
<http://example.org/rvk/AA-09900> a skos:Concept ;
28+
<http://rvk.uni-regensburg.de/nt/AA_09900> a skos:Concept ;
3129
dcterms:created "2012-07-05"^^xsd:date ;
3230
dcterms:identifier "3:" ;
3331
dcterms:modified "2017-09-12"^^xsd:date ;
34-
skos:broader <http://example.org/rvk/AA> ;
32+
skos:broader <http://rvk.uni-regensburg.de/nt/AA> ;
3533
skos:editorialNote "Erläuterungen zur Notationsvergabe s. RVK-Online - Nutzunghinweise"@de ;
36-
skos:inScheme <http://example.org/rvk> ;
34+
skos:inScheme <http://rvk.uni-regensburg.de/nt/> ;
3735
skos:notation "AA 09900" ;
3836
skos:prefLabel "Bibliographische Zeitschriften"@de .

mc2skos/mc2skos.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ def main():
217217
parser.add_argument('--uri', dest='base_uri', help='URI template')
218218
parser.add_argument('--scheme', dest='scheme_uri', help='SKOS scheme for all records, use {edition} to specify edition.')
219219
# parser.add_argument('--table_scheme', dest='table_scheme_uri', help='SKOS scheme for table records, use {edition} to specify edition.')
220+
parser.add_argument('--whitespace', dest='whitespace', metavar='STRING',
221+
help='Replace whitespaces in URI templates with this.')
220222

221223
parser.add_argument('--altlabels', '--indexterms', dest='altlabels', action='store_true',
222224
help='Include altlabels (from 7XX or 4XX).')
@@ -293,6 +295,7 @@ def main():
293295
options = {
294296
'base_uri': args.base_uri,
295297
'scheme_uri': args.scheme_uri,
298+
'whitespace': args.whitespace,
296299
'include_altlabels': args.altlabels,
297300
'exclude_notes': args.exclude_notes,
298301
'include_components': args.components,

mc2skos/record.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ def get_config(self, concept_type, code, options):
6767
return {
6868
'concept': options.get('base_uri'),
6969
'scheme': options.get('scheme_uri') or options.get('base_uri'),
70+
'whitespace': options.get('whitespace', '-'),
7071
}
7172

7273
try:
@@ -122,10 +123,6 @@ def get_uri(self, uri_type='concept', **kwargs):
122123
# Remove organization prefix in parenthesis:
123124
kwargs['control_number'] = re.sub(r'^\(.+\)(.+)$', '\\1', kwargs['control_number'])
124125

125-
if 'object' in kwargs:
126-
# replace spaces by hyphens
127-
kwargs['object'] = kwargs['object'].replace(' ', '-')
128-
129126
if uri_type not in self.config:
130127
raise UnknownSchemeError(scheme_code=self.code, **kwargs)
131128

@@ -156,7 +153,10 @@ def process_formatter(matches):
156153
uri_template
157154
)
158155

159-
return uri_template.format(**kwargs)
156+
uri = uri_template.format(**kwargs)
157+
158+
# replace whitespaces in URI
159+
return uri.replace(' ', self.config.get('whitespace', '-'))
160160

161161

162162
class Record(object):

mc2skos/vocabularies.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
---
22
classification_schemes:
3-
ddc: http://dewey.info/{collection}/{object}/e{edition}/
3+
asb: http://uri.gbv.de/terminology/asb/{object}
44
bkl: http://uri.gbv.de/terminology/bk/{object}
5+
ddc: http://dewey.info/{collection}/{object}/e{edition}/
6+
rvk:
7+
concept: http://rvk.uni-regensburg.de/nt/{object}
8+
scheme: http://rvk.uni-regensburg.de/nt/
9+
whitespace: _
510
utklklass:
611
concept: http://data.ub.uio.no/lklass/L{object[2:]}
712
scheme: http://data.ub.uio.no/lklass/
8-
asb: http://uri.gbv.de/terminology/asb/{object}
913
subject_schemes:
1014
a:
1115
concept: http://id.loc.gov/authorities/subjects/{control_number}

test/test_process_examples.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ def test_rvk_example(marc, match):
7575

7676
options = {
7777
'include_altlabels': True,
78-
'scheme_uri': 'http://example.org/rvk',
79-
'base_uri': 'http://example.org/rvk/{object}'
8078
}
8179

8280
check_processing(marc, Graph(), **options)

0 commit comments

Comments
 (0)