将marc/xml中的marc21分类记录转换为skos/rdf

mc2skos的Python项目详细描述


Build statusTest coverageCode healthLatest versionMIT license

用于转换的python脚本 MARC 21 ClassificationMARC 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 --helpmc2skos -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字段。

MARC21XMLRDF
^{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_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”@nb

webdewey数据的其他转换规则

脚本附带了一些额外的规则,用于区分 WebDewey记录并从中提取实体。实体提取规则(下面用[*]标记) 使用非标准命名空间,默认情况下不启用。将--webdewey标志指定为 使用它们。

MARC21XMLRDF
^{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…。

3月21日授权的映射架构

只有一小部分的marc21权限数据模型被转换。

MARC21XMLRDF
^{tt17}$ Control Number^{tt18}$
^{tt19}$ Date and time of latest transaction^{tt20}$
^{tt21}$ Date entered on file^{tt22}$
^{tt124}$ Other Classification Number^{tt125}$ (see below)
^{tt126}$ Universal Decimal Classification Number^{tt125}$ (see below)
^{tt128}$ Dewey Decimal Classification Number^{tt125}$ (see below)
^{tt130}$ Headings^{tt34}$
^{tt132}$ See From Tracings^{tt52}$
^{tt134}$ See Also From Tracings^{tt135}$, ^{tt38}$ or ^{tt137}$ (see below)
^{tt138}$ Nonpublic General Note^{tt40}$
^{tt140}$ Source Data Found^{tt141}$
^{tt142}$ Definition^{tt72}$
^{tt144}$ Biographical or Historical Data^{tt141}$
^{tt43}$ Public General Note^{tt141}$
^{tt148}$ Subject Example Tracing Note^{tt149}$
^{tt150}$ Deleted Heading Information^{tt151}$
^{tt152}$ Application History Note^{tt50}$
^{tt154}$ Heading Linking Entries^{tt155}$ (see below)

注意:

  • 只有当 已在配置中定义分类方案。
  • 如果字段包含^{tt156},则从5xx字段生成skos关系。$ 包含相关记录的控制号或uri的子字段。 关系类型是skos:broaderif$w=gskos:narrowerif$w=h, 否则skos:related。 如果$w=r$4包含uri,则该uri将用作关系类型。 注意$4必须在$0之前(因为两个子字段都可以重复)。
  • 如果字段包含^{tt156},则为7xx标题生成映射/关系。$ 包含相关记录的控制号或uri的子字段。 如果$0包含一个控制号,则为词汇表提供一个uri模式 (在指示符2或$2中找到)必须在mc2skos.record.config中定义。 如果$4包含uri,则该uri将用作关系类型。 否则,如果$4包含一个iso 25964关系,则 使用skos关系。否则,将使用默认值skos:closeMatch。 注意$4必须在$0之前(因为两个子字段都可以重复)。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java流/下载文件,无需在Spring Boot中保留内存   kotlin/java是否有类似TryParse()的东西?   java Spring引导找不到用户类型的属性ID   java Spring 2到Spring 3的迁移:一个控制器用于多个视图   java包含多个程序包名为“安卓”的库。支持图样可提取'   java spring JPA是否支持自定义值框架?   java转义出基于文本字段的搜索栏   java AAPT:错误:未找到样式属性“安卓:attr/WindowsPlashCreenBackground”   java从文本文件中读取纬度和经度   java哪里可以找到如何使用排序的示例。顺序ignorecase(),其中nullhandling nulls last用于自定义Spring JPA如何提供查询   尝试使用Dialogflow上的Webhook动态给出响应时,java获取Webhook响应错误(206)   如何在java中替换匹配的字符串?   java模拟数学的最大价值。随机的   java Spring RestTemplate GET请求未给出正确响应   春爪哇。lang.IllegalArgumentException   java系统。load()永远不会发生   java剪辑循环不工作   java如何从maven构建中删除staxapi   java ThreadPoolExecutor的排队行为是否可以自定义,以更喜欢创建新线程而不是排队?