Package: mc2skos
Python script for convertingMARC 21 ClassificationandMARC 21 Authorityrecords (serialized as MARCXML) toSKOSconcepts.Initially developed to support the
project “Felles terminologi for klassifikasjon med Dewey”,
for converting Dewey Decimal Classification (DDC) records.Issuesand
suggestions for generalizations and improvements are welcome!Seemapping schema for MARC21 Classificationandfor MARC21 Authoritybelow.InstallationReleases can be installed from the command line withpip:$pipinstall--upgrademc2skos# with virtualenv or as root$pipinstall--upgrade--usermc2skos# install to ~/.localWorks with both Python 2.7 and 3.4+. SeeTravisfor details on tested Python versions.If lxml fails to install on Windows, try the windows installer
fromfrom PyPI.If lxml fails to install on Unix, install system packages python-dev and libxml2-devMake sure the Python scripts folder has been added to your PATH.To directly use a version from source code repository:$gitclonehttps://github.com/scriptotek/mc2skos.git$cdmc2skos$pipinstall-e.Usagemc2skos infile.xml outfile.ttl      # from file to file
mc2skos infile.xml > outfile.ttl    # from file to standard outputRunmc2skos--helpormc2skos-hfor options.URIsURIs are generated automatically for known concept schemes, identified from084 $afor classification records and from008[11]/040 $ffor
authority records. To list known concept schemes:$mc2skos-lTo add more vocabularies, you can editvocabularies.yml.
Pull requests for adding more vocabularies are very welcome!URIs can be also be generated on the fly from an URI template specified with option--uri.  The following template parameters are recognized:{control_number}is the control number from 001, 010 or 016. The current approach
is to use 010 or 016 if defined, otherwise 001. If you find examples where this approach
fails, please add them to [#42](https://github.com/scriptotek/mc2skos/issues/42).{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. Spaces in the URI are replaced by hyphens or another character
configured with option–whitespace.{edition}is taken from084 $c(with language code stripped)To addskos:inSchemestatements to all records, an URI template can be
specified with option--scheme. Otherwise, it will be derived from a default
template if the concept scheme is known.To add an additionalskos:inSchemestatement to table records, an URI
template can be specified with option--table_scheme. Otherwise, it will be
derived from a default template if the concept scheme is known.The following example is generated from a DDC table record:<http://dewey.info/class/6--982/e21/>askos:Concept;skos:inScheme<http://dewey.info/scheme/edition/e21/>,<http://dewey.info/table/6/e21/>;skos:notation"T6--982";skos:prefLabel"Chibchan and Paezan languages"@en.Mapping schema for MARC21 ClassificationOnly a small part of the MARC21 Classification data model is converted, and the
conversion follows a rather pragmatic approach, exemplified by the mapping of
the 7XX fields to skos:altLabel.MARC21XMLRDF001Control Number  (see note above on 001, 010 & 016)dcterms:identifier005Date and time of latest transactiondcterms:modified008[0:6]Date entered on filedcterms:created008[8]="d"or "e"Classification validityowl:deprecated010Control Number (see note above on 001, 010 & 016)dcterms:identifier016Control Number (see note above on 001, 010 & 016)dcterms:identifier153 $a,$c,$zClassification numberskos:notation153 $jCaptionskos:prefLabel153 $e,$f,$zClassification number hierarchyskos:broader253Complex See Referenceskos:editorialNote353Complex See Also Referenceskos:editorialNote680Scope Noteskos:scopeNote683Application Instruction Noteskos:editorialNote684Auxiliary Instruction Noteskos:editorialNote685History Noteskos:historyNote700Index Term-Personal Nameskos:altLabel710Index Term-Corporate Nameskos:altLabel711Index Term-Meeting Nameskos:altLabel730Index Term-Uniform Titleskos:altLabel748Index Term-Chronologicalskos:altLabel750Index Term-Topicalskos:altLabel751Index Term-Geographic Nameskos:altLabel753Index Term-Uncontrolledskos:altLabel765Synthesized Number Componentsmads:componentList(see below)Synthesized number componentsComponents of synthesized numbers explicitly described in 765 fields are
expressed using themads:componentListproperty, and to preserve the order of the
components, we use RDF lists. Example:@prefixmads:<http://www.loc.gov/mads/rdf/v1#>.<http://dewey.info/class/001.30973/e23/>askos:Concept;mads:componentList(<http://dewey.info/class/001.3/e23/><http://dewey.info/class/1--09/e23/><http://dewey.info/class/2--73/e23/>);skos:notation"001.30973".Retrieving list membersin orderissurprisingly hardwith SPARQL.
Retrieving ordered pairs is the best solution I’ve come up with so far:PREFIX mads: <http://www.loc.gov/mads/rdf/v1#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>

SELECT ?c1_notation ?c1_label ?c2_notation ?c2_label
WHERE { GRAPH <http://localhost/ddc23no> {

    <http://dewey.info/class/001.30973/e23/> mads:componentList ?l .
        ?l rdf:rest* ?sl .
        ?sl rdf:first ?e1 .
        ?sl rdf:rest ?sln .
        ?sln rdf:first ?e2 .

        ?e1 skos:notation ?c1_notation .
        ?e2 skos:notation ?c2_notation .

        OPTIONAL {
            ?e1 skos:prefLabel ?c1_label .
        }
        OPTIONAL {
            ?e2 skos:prefLabel ?c2_label .
        }
}}c1_notationc1_labelc2_notationc2_label“001.3”“Humaniora”@nb“T1–09”“Historie, geografisk behandling, biografier”@nb“T1–09”“Historie, geografisk behandling, biografier”@nb“T2–73”“USA”@nbAdditional conversion rules for WebDewey dataThe script comes with a few extra rules for distinguishing between different types of notes in
WebDewey records and extract entities from these. The entity extraction rules (marked with [*] below)
utilizes a non-standard namespace and are not enabled by default. Specify the--webdeweyflag to
use them.MARC21XMLRDF680having$9 ess=ndfDefinition noteskos:definition680having$9 ess=nvnVariant name notewd:variantName[*] for each subfield$t680having$9 ess=nchClass here notewd:classHere[*] for each subfield$t680having$9 ess=ninIncluding notewd:including[*] for each subfield$t680having$9 ess=nphFormer headingwd:formerHeading[*] for each subfield$t694having$9 ess=nml???SKOS.editorialNote7XXhaving$9 ess=isCaptionRelative index term to use as captionskos:prefLabelNotes that are currently not treated in any special way:253having$9 ess=nsxDo-not-use.253having$9 ess=nceClass-elsewhere253having$9 ess=ncwClass-elsewhere-manual253having$9 ess=nseSee.253having$9 ess=nswSee-manual.353having$9 ess=nsaSee-also683having$9 ess=nbuPreference note683having$9 ess=nopOptions note683having$9 ess=nonOptions note684having$9 ess=nsmManual note685having$9 ess=ndpDiscontinued partial685having$9 ess=nrpRelocation689having$9 ess=nruSist brukt i…Mapping schema for MARC21 AuthorityOnly a small part of the MARC21 Authority data model is converted.MARC21XMLRDF001Control Numberdcterms:identifier005Date and time of latest transactiondcterms:modified008[0:6]Date entered on filedcterms:created065Other Classification Numberskos:exactMatch(see below)080Universal Decimal Classification Numberskos:exactMatch(see below)083Dewey Decimal Classification Numberskos:exactMatch(see below)1XXHeadingsskos:prefLabel4XXSee From Tracingsskos:altLabel5XXSee Also From Tracingsskos:related,skos:broaderorskos:narrower(see below)667Nonpublic General Noteskos:editorialNote670Source Data Foundskos:note677Definitionskos:definition678Biographical or Historical Dataskos:note680Public General Noteskos:note681Subject Example Tracing Noteskos:example682Deleted Heading Informationskos:changeNote688Application History Noteskos:historyNote7XXHeading Linking Entriesskos:xxxMatch(see below)Notes:Mappings are generated for 065, 080 and 083 only if an URI pattern for the
classification scheme has been defined in the config.SKOS relations are generated from 5XX fields if the fields contain a$0subfield containing either a control number or an URI for the related record.
The relationship type isskos:broaderif$w=g,skos:narrowerif$w=h,
andskos:relatedotherwise.
If$w=rand$4contains an URI, that URI is used as the relationship type.
Note that$4must precede$0(since both subfields can be repeated).Mappings/relationships are generated for 7XX headings if the fields contain a$0subfield containing either the control number or the URI of the related record.
If$0contains a control number, an URI pattern for the vocabulary
(found in indicator 2 or$2) must be defined in mc2skos.record.CONFIG.
If$4contains an URI, that URI is used as the relationship type.
Otherwise, if$4contains one of the ISO 25964 relations, the corresponding
SKOS relation is used. Otherwise, the default valueskos:closeMatchis used.
Note that$4must precede$0(since both subfields can be repeated).