将marc/xml中的marc21分类记录转换为skos/rdf
mc2skos的Python项目详细描述
用于转换的python脚本 MARC 21 Classification 和 MARC 21 Authority 记录(序列化为marcXML)到 SKOS概念。
最初是为了支持 项目“Felles terminologi for klassifikasjon med Dewey”, 用于转换杜威十进制分类(DDC)记录。 Issues和 欢迎总结和改进意见!
见mapping schema for MARC21 Classification 以及下面的for MARC21 Authority。
安装
可以使用pip:
$ pip install --upgrade mc2skos # with virtualenv or as root $ pip install --upgrade --user mc2skos # install to ~/.local
- 同时适用于Python2.7和3.4+。见Travis 有关测试的python版本的详细信息。
- 如果lxml无法在windows上安装,请尝试windows安装程序 来自from PyPI。
- 如果lxml无法在unix上安装,请安装系统包python dev和libxml2 dev
- 确保python脚本文件夹已添加到您的路径中。
直接使用源代码存储库中的版本:
$ git clone https://github.com/scriptotek/mc2skos.git $cd mc2skos $ pip install -e .
用法
mc2skos infile.xml outfile.ttl # from file to file
mc2skos infile.xml > outfile.ttl # from file to standard output
运行mc2skos --help或mc2skos -h获取选项。
uri
为已知的概念方案自动生成uri,从 084 $a用于分类记录,从008[11]/040 $f用于 权威记录。列出已知的概念方案:
$ mc2skos -l
要添加更多词汇表,可以编辑 vocabularies.yml。 非常欢迎您提出添加更多词汇的请求!
uri也可以从用option指定的uri模板动态生成 --uri。可以识别以下模板参数:
- {control_number}是001、010或016的控制号。当前方法 使用010或016(如果定义),否则使用001。如果你发现这种方法的例子 失败,请将它们添加到[42](https://github.com/scriptotek/mc2skos/issues/42)。
- {collection}是“类”、“表”或“方案”
- {object}是分类方案的成员,也是{collection}的一部分,例如 作为一个特定的类或表。uri中的空格被连字符或其他字符替换 配置了选项–空白。
- {edition}取自084 $c(去掉语言代码)
要将skos:inScheme语句添加到所有记录,可以使用 使用选项--scheme指定。否则,将从默认值派生 模板(如果概念方案已知)。
若要向表记录中添加附加的skos:inScheme语句,请使用uri 可以使用选项--table_scheme指定模板。否则,它将 如果概念方案已知,则从默认模板派生。
下面的示例是从DDC表记录生成的:
<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.
3月21日分类的映射模式
只有一小部分的marc21分类数据模型被转换,并且 转换遵循一种相当实用的方法,例如 skos:altlabel的7xx字段。
MARC21XML | RDF |
---|---|
^{tt17}$ Control Number (see note above on 001, 010 & 016) | ^{tt18}$ |
^{tt19}$ Date and time of latest transaction | ^{tt20}$ |
^{tt21}$ Date entered on file | ^{tt22}$ |
^{tt23}$ Classification validity | ^{tt24}$ |
^{tt25}$ Control Number (see note above on 001, 010 & 016) | ^{tt18}$ |
^{tt27}$ Control Number (see note above on 001, 010 & 016) | ^{tt18}$ |
^{tt29}$, ^{tt30}$, ^{tt31}$ Classification number | ^{tt32}$ |
^{tt33}$ Caption | ^{tt34}$ |
^{tt35}$, ^{tt36}$, ^{tt31}$ Classification number hierarchy | ^{tt38}$ |
^{tt39}$ Complex See Reference | ^{tt40}$ |
^{tt41}$ Complex See Also Reference | ^{tt40}$ |
^{tt43}$ Scope Note | ^{tt44}$ |
^{tt45}$ Application Instruction Note | ^{tt40}$ |
^{tt47}$ Auxiliary Instruction Note | ^{tt40}$ |
^{tt49}$ History Note | ^{tt50}$ |
^{tt51}$ Index Term-Personal Name | ^{tt52}$ |
^{tt53}$ Index Term-Corporate Name | ^{tt52}$ |
^{tt55}$ Index Term-Meeting Name | ^{tt52}$ |
^{tt57}$ Index Term-Uniform Title | ^{tt52}$ |
^{tt59}$ Index Term-Chronological | ^{tt52}$ |
^{tt61}$ Index Term-Topical | ^{tt52}$ |
^{tt63}$ Index Term-Geographic Name | ^{tt52}$ |
^{tt65}$ Index Term-Uncontrolled | ^{tt52}$ |
^{tt67}$ Synthesized Number Components | ^{tt68}$ (see below) |
合成数成分
765个字段中明确描述的合成数的组成部分是 使用mads:componentlist属性表示,并保留 组件,我们使用RDF列表。示例:
@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".
从SeqQL中检索列表成员^ {EM1}$为EEE> ^ surprisingly hard。 检索有序对是迄今为止我提出的最佳解决方案:
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_notation | c1_label | c2_notation | c2_label |
---|---|---|---|
“001.3” | “Humaniora”@nb | “T1–09” | “Historie, geografisk behandling, biografier”@nb |
“T1–09” | “Historie, geografisk behandling, biografier”@nb | “T2–73” | “USA”@nb |
webdewey数据的其他转换规则
脚本附带了一些额外的规则,用于区分 WebDewey记录并从中提取实体。实体提取规则(下面用[*]标记) 使用非标准命名空间,默认情况下不启用。将--webdewey标志指定为 使用它们。
MARC21XML | RDF |
---|---|
^{tt43}$ having ^{tt71}$ Definition note | ^{tt72}$ |
^{tt43}$ having ^{tt74}$ Variant name note | ^{tt75}$ [*] for each subfield ^{tt76}$ |
^{tt43}$ having ^{tt78}$ Class here note | ^{tt79}$ [*] for each subfield ^{tt76}$ |
^{tt43}$ having ^{tt82}$ Including note | ^{tt83}$ [*] for each subfield ^{tt76}$ |
^{tt43}$ having ^{tt86}$ Former heading | ^{tt87}$ [*] for each subfield ^{tt76}$ |
^{tt89}$ having ^{tt90}$ ??? | ^{tt91}$ |
当前未以任何特殊方式处理的注释:
- ^有$9 ess=nsx的{tt39}$不使用。
- 253在别处有$9 ess=nce类
- 253在别处有$9 ess=ncw类手册
- 253有$9 ess=nse请参阅。
- 253公顷ving$9 ess=nsw请参阅手册。
- 353具有$9 ess=nsa另请参见
- 683具有$9 ess=nbu首选项注释
- 683具有$9 ess=nop选项注释
- 683具有$9 ess=non选项注释
- 684有$9 ess=nsm手册注释
- 685有$9 ess=ndp部分中断
- 685具有$9 ess=nrp重新定位
- 689有$9 ess=nrusist brukt i…。