簡體   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