繁体   English   中英

使用Jena编写dataTypeProperties后,Protege Reasoner弹出错误

[英]Protege Reasoner popups errors after writing dataTypeProperties using Jena

我创造了本体。 我有一些dataTypeProperties,其范围设置为整数,dateTime和字符串。

在我的Java应用程序中,我正在使用Jena api写入owl文件,我正在使用此单一方法处理dataTypeProperties:

public void setDataTypeProperty(String resourceURI, String propertyName, String propertyValue) 
{
    if (resourceURI==null)
    return;

    Model model = ModelFactory.createDefaultModel();

    //read model from file
    InputStream in = FileManager.get().open(inputFileName);

     if (in == null) 
     {
         throw new IllegalArgumentException( "File: " + inputFileName + " not found");
     }       
     model.read(in, "");
     try {
        in.close();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


     // Add property to Model
     Resource resource = model.createResource(resourceURI);
     resource.addProperty(model.createProperty(baseURI+propertyName), model.createLiteral(propertyValue));


     //Writing model to file
        try {
            FileWriter out = new FileWriter( inputFileName );
            model.write( out, "RDF/XML-ABBREV" );
            out.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 
}

写入owl文件后,如下所示:

....
<File rdf:about="http://www.semanticweb.org/administrator/ontologies/2014/2/untitled-ontology-5#677f5c75-7527-45e2-8430-829466027034"> 
    <filePeakLocation>ismaila swabi</filePeakLocation> //String Datatype
    <filePeakDay>6</filePeakDay> //Integer Datatype 
    <fileLastAccessed>2014-07-26T13:17:49</fileLastAccessed> //dateTime
    <created>2014-07-26T13:17:27</created> //dateTime
    <hasPath>/examples/run.sh</hasPath>  //String Datatype
    <fileAccessedLocation>ismaila swabi_atTime_2014-07-26T13:17:49</fileAccessedLocation>
    <filePeakHour>13</filePeakHour> //Integer
</File>
....

问题是,现在如果我打开protege的owl文件并运行推理程序(Fact ++),则会弹出如下错误:

在此处输入图片说明

推理机显示的所有错误都是具有整数或dataTime数据类型范围的属性。 具有范围的属性没有错误。

有人可以指出错误的原因吗?

我非常确定问题是您正在使用此单个函数public void setDataTypeProperty()编写字符串,整数和dateTime。 您的函数将所有值写为纯文字。 您应该检查TypedLiterals

model.createTypedLiteral(arg0)尝试model.createTypedLiteral(arg0)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM