1
나는 protege 4.2로 작성한 올빼미 파일을 가지고 있습니다. Jena로 인스턴스를 추가하면 Jena는 파일 구조를 변경하지만 파일 확장자는 동일하게 유지됩니다. (.owl) 파일은 일부 오류가있는 protege에서 읽을 수 있습니다. 누구든지 내 코드의 문제점을 알고 있습니까?Jena가 인스턴스를 추가 한 후 올빼미 파일을 변경합니다.
예나로 편집 한 후 sparql 쿼리의 결과가 이상하게 이상합니다.
예를 들어, 예나
와 편집하기 전에<owl:NamedIndividual rdf:about="&ontologies;thesis_ontology_1try#AM6">
<rdf:type rdf:resource="&ontologies;thesis_ontology_1try#ApplicationModel"/>
<hasID rdf:datatype="&xsd;string">20125157-d62b-45de-8809-84186c7169b5AM6</hasID>
<name rdf:datatype="&xsd;string">Gebäudemodell/Buildingmodel</name>
<hasContent rdf:resource="&ontologies;cpixml"/>
<hasLevelOfDetail rdf:resource="&ontologies;thesis_ontology_1try#4"/>
<hasDomain rdf:resource="&ontologies;thesis_ontology_1try#BIM"/>
<hasType rdf:resource="&ontologies;thesis_ontology_1try#Object"/>
<hasPhase rdf:resource="&ontologies;thesis_ontology_1try#SLCT"/>
<hasContent rdf:resource="&ontologies;thesis_ontology_1try#ifc"/>
</owl:NamedIndividual>
예나
<rdf:Description rdf:about="http://www.semanticweb.org/thato/ontologies/2012/10/9/thesis_ontology_1try#AM6">
<hasContent rdf:resource="http://www.semanticweb.org/thato/ontologies/2012/10/9/cpixml"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
<hasDomain rdf:resource="http://www.semanticweb.org/thato/ontologies/2012/10/9/thesis_ontology_1try#BIM"/>
<hasType rdf:resource="http://www.semanticweb.org/thato/ontologies/2012/10/9/thesis_ontology_1try#Object"/>
<hasID rdf:datatype="http://www.w3.org/2001/XMLSchema#string">20125157-d62b-45de-8809-84186c7169b5AM6</hasID>
<hasPhase rdf:resource="http://www.semanticweb.org/thato/ontologies/2012/10/9/thesis_ontology_1try#SLCT"/>
<rdf:type rdf:resource="http://www.semanticweb.org/thato/ontologies/2012/10/9/thesis_ontology_1try#ApplicationModel"/>
<hasContent rdf:resource="http://www.semanticweb.org/thato/ontologies/2012/10/9/thesis_ontology_1try#ifc"/>
<name rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Gebäudemodell/Buildingmodel</name>
<hasLevelOfDetail rdf:resource="http://www.semanticweb.org/thato/ontologies/2012/10/9/thesis_ontology_1try#4"/>
<rdf:type rdf:nodeID="A28"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
<rdf:type rdf:nodeID="A29"/>
<rdf:type rdf:nodeID="A30"/>
<rdf:type rdf:nodeID="A31"/>
<rdf:type rdf:nodeID="A32"/>
<rdf:type rdf:resource="http://www.w3.org/2000/01/rdf-schema#Resource"/>
<rdf:type rdf:nodeID="A33"/>
<rdf:type rdf:nodeID="A34"/>
<rdf:type rdf:nodeID="A12"/>
<rdf:type rdf:nodeID="A15"/>
<rdf:type rdf:nodeID="A35"/>
<rdf:type rdf:nodeID="A5"/>
<Linkedby rdf:resource="http://www.semanticweb.org/thato/ontologies/2012/10/9/thesis_ontology_1try#LM2"/>
<isAMof rdf:resource="http://www.semanticweb.org/thato/ontologies/2012/10/9/thesis_ontology_1try#MMC2"/>
후이 코드
public static void main(String[] args) throws IOException {
InputStream in = FileManager.get().open("./src/thesis_ontology_1try.owl");
OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, null);
model.read(in, null);
in.close();
String NS = "http://www.semanticweb.org/thato/ontologies/2012/10/9/thesis_ontology_1try#";
OntClass ApplicationModel = model.getOntClass(NS + "ApplicationModel");
Individual dom = model.getIndividual(NS + "RFP");
Individual pha = model.getIndividual(NS + "SLCT");
Individual lev = model.getIndividual(NS + "3");
Individual new1 = model.createIndividual(NS + "new1", ApplicationModel);
ObjectProperty domain = model.createObjectProperty(NS +"hasDomain");
ObjectProperty phase = model.createObjectProperty(NS +"hasPhase");
ObjectProperty lod = model.createObjectProperty(NS +"hasLevelOfDetail");
model.add(new1, domain, dom);
model.add(new1, phase, pha);
model.add(new1, lod, lev);
PrintStream p= new PrintStream("./src/thesis_ontology_1try.owl");
model.writeAll(p, "RDF/XML", null);
p.close();
System.out.println("Done");
}
}
많은 개인, 클래스 및 관계가있는 약 20MB의 rdf 파일이 있습니다. about 메소드를 사용하여 rdf 파일에 새 개인을 추가 할 때 많은 시간이 걸리고 마침내 메모리 부족 GC가 발생합니다. 변경 사항을 작성하는 더 좋은 방법이 있습니까? – Proceso