0

在以下代码中,ValidityReport 始终有效;没有检测到不一致。我希望它应该给我一个警告,因为我正在为 FOAF 文件提供姓氏。为什么没有检测到不一致?

    Model model = ModelFactory.createDefaultModel();
    OntModel m = ModelFactory.createOntologyModel();
    m.read(FOAF.NS);
    Resource persona = model.createResource("http://www.example.org/rdf#Persona", FOAF.Document);
    persona.addProperty(FOAF.family_name, "18", XSDDatatype.XSDint);
    InfModel infModel = ModelFactory.createRDFSModel(m, model);
    ValidityReport validity = infModel.validate();
    if (validity.isValid()) {
      System.out.println("Valid!");
    } else {
      System.out.println("Conflicts");
      for (Iterator<Report> in = validity.getReports(); in.hasNext();) {
        System.out.println(" - " + in.next());
      }
    }
4

1 回答 1

2

您正在创建的实例数据是这样的:

@prefix ex:    <http://www.example.org/rdf#> .
@prefix foaf:  <http://xmlns.com/foaf/0.1/> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .

ex:Persona  a             foaf:Document ;
        foaf:family_name  "18"^^xsd:int .

有一个 type 的资源foaf:Document,它具有该属性 的xsd:int值。foaf:family_name

您的推理模型使用 RDFS 推理器。的域foaf:family_name(顺便说一句,被描述为 的古老拼写foaf:familyName)是foaf:Person,因此ex:Persona可以推断为foaf:Person,正如我们在编写推理模型时看到的那样。ex:Persona推断还有许多其他类型:

ex:Persona  a             foaf:Document , foaf:Person , <http://www.w3.org/2000/01/rdf-schema#Resource> , <http://www.w3.org/2003/01/geo/wgs84_pos#SpatialThing> , foaf:Agent ;
        foaf:family_name  "18"^^xsd:int .

在 RDFS 模型中存在不一致是相当困难的,因为你不能真正说出很多。例如,您不能声明不相交的类,因此 afoaf:Document a之间没有矛盾foaf:Person

即使您使用 OWL 推理器,您仍然需要查明一些特定的逻辑不一致。我不知道这些类型中是否有任何ex:Persona不相交的,如果它们不是(或者如果推理者无法推断它们是),你就不会发现不一致。

于 2014-02-25T23:38:09.890 回答