在文件

时间:2019-05-20 16:41:31

标签: rdf jena ontology protege

我的Java程序正在读取医学数据并将其转换为语义,然后将其另存为RDF文件以导出它们。但是文件中总是存在一个来自特定类别的人,但是缺少某些属性及其所属的类别。

我试图更改导出格式,我仔细检查了所有IRI。所有这些都没有成功。

在添加模型到RDF文件中之前,我添加了一些代码来检查类和属性,一切似乎都是正确的。

创建本体的代码:

    public static Individual createIndiv(String name, Resource ressource) {                 // Create an Individual
        if (populateModel==null) {populateModel = ModelFactory.createOntologyModel();}
        if (name==null || ressource==null) {
            logger.error("Creating Individual named "+name+" with classs "+ressource.getLocalName());
            return null;
        } else {
            logger.debug("Creating Individual named "+name+" with classs "+ressource.getLocalName());
            System.out.println(ressource);
            Individual ind = populateModel.createIndividual(racineURI+name, ressource);
            return ind;
        }
    }

        Individual imagingStudy = createIndiv(generateName("imaging_study_TEST"), model.getResource("http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#imaging_study"));    

编写之前要检查的测试:

        System.out.println("Test Final :");
        System.out.println("RDF Type :"+imagingStudy.getRDFType());
        StmtIterator propertiesIter = imagingStudy.listProperties();
        Statement p;
        while (propertiesIter.hasNext()) {
            p = propertiesIter.next();
            System.out.println(p.asTriple());
        }

用于编写模型的代码:

    public void writingRDF(String pathOut) throws FileNotFoundException  {                                                              // Write the RDF 
        logger.info("Writing RDF file in "+pathOut);        

        FileOutputStream sortie = new FileOutputStream(pathOut);
        OntologyPopulator.populateModel.write(sortie, "RDF/XML", null);                 

        logger.info("Writing RDF file Sucessfull");
        OntologyPopulator.populateModel = ModelFactory.createOntologyModel();
    }

简短的RDF文件:

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:j.0="http://purl.obolibrary.org/obo/"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:j.1="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
  <owl:ObjectProperty rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#part_of_study"/>
  <owl:ObjectProperty rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#is_about_procedure"/>
  <owl:ObjectProperty rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#has_protocol"/>
  <owl:ObjectProperty rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#used_as_instrument_in"/>
  <owl:ObjectProperty rdf:about="http://purl.obolibrary.org/obo/BFO_0000052"/>
  <owl:ObjectProperty rdf:about="http://purl.obolibrary.org/obo/BFO_0000087"/>
  <owl:ObjectProperty rdf:about="http://purl.obolibrary.org/obo/BFO_0000132"/>
  <owl:ObjectProperty rdf:about="http://purl.obolibrary.org/obo/BFO_0000054"/>
  <owl:DatatypeProperty rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#years"/>
  <owl:DatatypeProperty rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#has_id"/>
  <owl:DatatypeProperty rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#has_manufacturer_name"/>
  <owl:DatatypeProperty rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#has_description"/>
  <owl:DatatypeProperty rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#has_name"/>
  <owl:DatatypeProperty rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#has_DICOM_study_instance_UID"/>
  <owl:DatatypeProperty rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#has_DICOM_series_instance_UID"/>
  <owl:DatatypeProperty rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#has_beginning_time"/>
  <owl:DatatypeProperty rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#has_beginning_date"/>
  <owl:DatatypeProperty rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#has_model_name"/>
  <j.1:age_of_patient_undergoing_medical_procedure rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#age_of_patient_undergoing_medical_procedure_1cf4387d-b276-4f86-8e6d-52eb48833afd">
    <j.1:is_about_procedure>
      <rdf:Description rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#imaging_study_TEST_ec26ee5a-c016-4b20-9c90-cce7315ea2c7">
        <j.1:part_of_study>
          <j.1:clinical_research_study rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#clinical_research_study_755523_subtask2.1.2"/>
        </j.1:part_of_study>
      </rdf:Description>
    </j.1:is_about_procedure>
    <j.1:years rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal"
    >36</j.1:years>
  </j.1:age_of_patient_undergoing_medical_procedure>
  <j.1:patient rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#Patient_4c7681a8-176b-4940-abbd-27fb9df399f7">
    <j.0:BFO_0000054>
      <j.1:SPECT_data_acquisition rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#SPECT_data_acquisition_c8bd9ca2-70c1-4cd5-b52b-2295db407922">
        <j.1:has_DICOM_series_instance_UID>1.3.12.2.1107.5.6.1.9225.30500109020320314446800000119</j.1:has_DICOM_series_instance_UID>
        <j.1:has_beginning_time>073900.000000</j.1:has_beginning_time>
        <j.1:has_beginning_date>20090211</j.1:has_beginning_date>
        <j.1:has_id>1000</j.1:has_id>
        <j.0:BFO_0000132 rdf:resource="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#imaging_study_TEST_ec26ee5a-c016-4b20-9c90-cce7315ea2c7"/>
        <j.1:has_protocol>
          <j.1:NM_acquisition_protocol rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#NM_acquisition_protocol_950491e0-2b97-4c5a-89d6-044852ead542">
            <j.1:has_description>Spect 131-I</j.1:has_description>
            <j.1:has_name>7312.0.21354437@</j.1:has_name>
          </j.1:NM_acquisition_protocol>
        </j.1:has_protocol>
      </j.1:SPECT_data_acquisition>
    </j.0:BFO_0000054>
    <j.0:BFO_0000054 rdf:resource="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#imaging_study_TEST_ec26ee5a-c016-4b20-9c90-cce7315ea2c7"/>
  </j.1:patient>
  <j.1:SPECT_scanner rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#SPECT_scanner_39a89288-4f79-49c7-ac18-f59dec9786bf">
    <j.0:BFO_0000087>
      <j.1:image_acquisition_role rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#image_acquisition_role_28318df2-49ec-45a4-a59e-233fc371e729">
        <j.0:BFO_0000054 rdf:resource="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#SPECT_data_acquisition_c8bd9ca2-70c1-4cd5-b52b-2295db407922"/>
      </j.1:image_acquisition_role>
    </j.0:BFO_0000087>
    <j.1:has_model_name>IP2</j.1:has_model_name>
    <j.1:has_manufacturer_name>SIEMENS NM</j.1:has_manufacturer_name>
    <j.1:used_as_instrument_in rdf:resource="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#SPECT_data_acquisition_c8bd9ca2-70c1-4cd5-b52b-2295db407922"/>
  </j.1:SPECT_scanner>
  <rdf:Description rdf:about="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#role_of_responsible_organization_e147d526-332d-40df-8df8-80a63e0b4a22">
    <j.0:BFO_0000052 rdf:resource="http://medicis.univ-rennes1.fr/ontologies/ontospm/OntoMEDIRAD.owl#institution_700f9e9c-9cb6-461f-b7d6-42a995583523"/>
  </rdf:Description>
  <j.0:PATO_0000383 rdf:about="http://purl.obolibrary.org/obo/PATO_0000383"/>
</rdf:RDF>

测试中显示的属性(可以) 1班 4个住宿

Protégé中的Imaging_Study个人 没课 仅2个属性

谢谢您的帮助

1 个答案:

答案 0 :(得分:0)

我找到了解决方法

函数中有一条代码行,用于创建另一个人,该行正在删除模型并创建新模型。

谢谢您的回答