8

如何将数据类型属性的范围指定为 xsd:strings,其文字形式与 [AZ] 匹配?至少乍一看,OWL 限制对我没有用。有没有办法用正则表达式做到这一点,如果有,在哪里?

4

3 回答 3

5

我想您的意思是“单个大写字母”,即string[pattern "[A-Z]"].

如果您使用 Protege,请将其输入到“数据范围表达式”选项卡中。

HermiT 1.3.7 可以检查这一点并提供关于不一致的属性值的解释。

于 2013-05-24T08:58:03.113 回答
2

其他答案解释说,这可以使用 XSD 方面将属性的字符串范围限制为与模式匹配的字符串范围[A-Z],但没有显示结果 RDF。我在 Protégé 中创建了一个非常简单的本体并定义了一个数据属性hasLatinInitial。如其他答案所述,范围指定为string[pattern "[A-Z]"]。然后我创建了一个人JohnDoe并添加了数据属性断言

JohnDoe hasLatinInitial "J" .
JohnDoe hasLatinInitial "D" .

HermiT 1.3.7 确实运行并且报告没有不一致。然后我添加了断言

JohnDoe hasLatinInitial "3" .

和 HermiT 1.3.7 报告了不一致:

在此处输入图像描述

以下是生成的本体在 N3 和 RDF/XML 中的样子:

@prefix :        <http://www.example.com/example#> .
@prefix rdfs:    <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl:     <http://www.w3.org/2002/07/owl#> .
@prefix xsd:     <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix example:  <http://www.example.com/example#> .

<http://www.example.com/example>
      a       owl:Ontology .

example:hasLatinInitial
      a       owl:DatatypeProperty ;
      rdfs:range
              [ a       rdfs:Datatype ;
                owl:onDatatype xsd:string ;
                owl:withRestrictions
                        ([ xsd:pattern "[A-Z]"
                          ])
              ] .

example:JohnDoe
      a       owl:NamedIndividual ;
      example:hasLatinInitial
              "3" , "J" , "D" 
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:example="http://www.example.com/example#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
  <owl:Ontology rdf:about="http://www.example.com/example"/>
  <owl:DatatypeProperty rdf:about="http://www.example.com/example#hasLatinInitial">
    <rdfs:range>
      <rdfs:Datatype>
        <owl:onDatatype rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <owl:withRestrictions rdf:parseType="Collection">
          <rdf:Description>
            <xsd:pattern>[A-Z]</xsd:pattern>
          </rdf:Description>
        </owl:withRestrictions>
      </rdfs:Datatype>
    </rdfs:range>
  </owl:DatatypeProperty>
  <owl:NamedIndividual rdf:about="http://www.example.com/example#JohnDoe">
    <example:hasLatinInitial>3</example:hasLatinInitial>
    <example:hasLatinInitial>D</example:hasLatinInitial>
    <example:hasLatinInitial>J</example:hasLatinInitial>
  </owl:NamedIndividual>
</rdf:RDF>

于 2013-05-24T14:48:51.963 回答
1

曼彻斯特语法中的以下表达式应该可以解决问题:

string[pattern "A-Z"]

您可以将其直接作为 Protege 中的数据范围。我不确定是什么推理者正在实施该构造,但我以前从未使用过它。

更多信息:http ://www.w3.org/TR/owl2-manchester-syntax/#facet

于 2013-05-24T08:48:53.897 回答