diff --git a/README.rst b/README.rst index 339285d..06501b4 100644 --- a/README.rst +++ b/README.rst @@ -89,8 +89,8 @@ URIs can be also be generated on the fly from an URI template specified with opt * ``{control_number}`` is the 001 value * ``{collection}`` is "class", "table" or "scheme" -* ``{object}`` is a member of the classification scheme and part of - a ``{collection}``, such as a specific class or table. +* ``{object}`` is a member of the classification scheme (with spaces replaced by + hyphens) and part of a ``{collection}``, such as a specific class or table. * ``{edition}`` is taken from ``084 $c`` (with language code stripped) diff --git a/examples/asb-ubk-2.ttl b/examples/asb-ubk-2.ttl new file mode 100644 index 0000000..05970e7 --- /dev/null +++ b/examples/asb-ubk-2.ttl @@ -0,0 +1,23 @@ +@prefix dcterms: . +@prefix owl: . +@prefix rdf: . +@prefix rdfs: . +@prefix skos: . +@prefix xml: . +@prefix xsd: . + + a skos:Concept ; + skos:altLabel "Astronomie / Atlas"@de, + "Astronomie / Aufgabensammlung / Allgemeines"@de, + "Astronomie / Bibliographie / Allgemeines"@de, + "Astronomie / Formelsammlung / Allgemeines"@de, + "Astronomie / Nachschlagewerk / Allgemeines"@de, + "Astronomie / Tabellensammlung / Allgemeines"@de, + "Weltraum / Atlas"@de ; + skos:broader ; + skos:editorialNote "Spezielle Nachschlagewerke und Bibliographien s. Ubk 5 bis Ubm 3"@de ; + skos:inScheme ; + skos:notation "Ubk 2" ; + skos:prefLabel "Nachschlagewerke. Bibliographien"@de ; + skos:scopeNote "Formel- und Tabellensammlungen"@de . + diff --git a/examples/asb-ubk-2.xml b/examples/asb-ubk-2.xml new file mode 100644 index 0000000..9af37ef --- /dev/null +++ b/examples/asb-ubk-2.xml @@ -0,0 +1,47 @@ + + + + *****nw###22*****n##4500 + + DE-Rt5 + ger + + + asb + ger + DE-Rt5 + + + Ubk 2 + Ubk + Nachschlagewerke. Bibliographien + + + Formel- und Tabellensammlungen + + + Spezielle Nachschlagewerke und Bibliographien s. Ubk 5 bis Ubm 3 + + + Astronomie / Atlas + + + Astronomie / Aufgabensammlung / Allgemeines + + + Astronomie / Bibliographie / Allgemeines + + + Astronomie / Formelsammlung / Allgemeines + + + Astronomie / Nachschlagewerk / Allgemeines + + + Astronomie / Tabellensammlung / Allgemeines + + + Weltraum / Atlas + + + diff --git a/mc2skos/record.py b/mc2skos/record.py index 908d33d..82ddc8e 100644 --- a/mc2skos/record.py +++ b/mc2skos/record.py @@ -122,6 +122,10 @@ def get_uri(self, uri_type='concept', **kwargs): # Remove organization prefix in parenthesis: kwargs['control_number'] = re.sub('^\(.+\)(.+)$', '\\1', kwargs['control_number']) + if 'object' in kwargs: + # replace spaces by hyphens + kwargs['object'] = kwargs['object'].replace(' ', '-') + if uri_type not in self.config: raise UnknownSchemeError(scheme_code=self.code, **kwargs) diff --git a/mc2skos/vocabularies.yml b/mc2skos/vocabularies.yml index 8b35c15..509d2d3 100644 --- a/mc2skos/vocabularies.yml +++ b/mc2skos/vocabularies.yml @@ -5,6 +5,7 @@ classification_schemes: utklklass: concept: http://data.ub.uio.no/lklass/L{object[2:]} scheme: http://data.ub.uio.no/lklass/ + asb: http://uri.gbv.de/terminology/asb/{object} subject_schemes: a: concept: http://id.loc.gov/authorities/subjects/{control_number} diff --git a/tests/test_process_examples.py b/tests/test_process_examples.py index be30662..0ed9ef5 100644 --- a/tests/test_process_examples.py +++ b/tests/test_process_examples.py @@ -73,15 +73,16 @@ def test_ddc_example(marc_file): check_rdf(graph, expect, rdf_file) -@pytest.mark.parametrize('marc_file', examples('bk-(?P[0-9.]+)')) -def test_bk_example(marc_file): +@pytest.mark.parametrize('marc_file', examples('(?Pbk|asb)-(?P[0-9.]+)')) +def test_bk_asb_example(marc_file): marc, match = tuple(marc_file) + scheme = match.group('scheme') notation = match.group('notation') rdf_file = match.group(1) + '.ttl' expect = Graph() - uri = URIRef(u'http://uri.gbv.de/terminology/bk/' + notation) + uri = URIRef(u'http://uri.gbv.de/terminology/{}/{}'.format(scheme, notation)) expect.add((uri, RDF.type, SKOS.Concept)) graph = marc.processed_records(include_altlabels=True)