Io Jena修改了一个模型,如何将这个owl文件重新加载到Protege
如标题所示,我将Protege生成的owl文件读取到Jena,通过添加一些NamedIndividuals对其进行了修改,我想读取Protege修改后的文件。事情进展顺利,直到我和Protege打开这个owl文件。学生就是看不懂! 我尝试了每一个“RDF/XML”、“RDF/XML-ABBREV”、“N-TRIPLE”、“TTL”,但仍然一无所获 一个好消息是,当我使用“RDF/XML-ABBREV”并删除我添加的所有NamedIndividual时,Protege可以工作。 但是我想要我的个人Io Jena修改了一个模型,如何将这个owl文件重新加载到Protege,io,jena,ontology,protege,Io,Jena,Ontology,Protege,如标题所示,我将Protege生成的owl文件读取到Jena,通过添加一些NamedIndividuals对其进行了修改,我想读取Protege修改后的文件。事情进展顺利,直到我和Protege打开这个owl文件。学生就是看不懂! 我尝试了每一个“RDF/XML”、“RDF/XML-ABBREV”、“N-TRIPLE”、“TTL”,但仍然一无所获 一个好消息是,当我使用“RDF/XML-ABBREV”并删除我添加的所有NamedIndividual时,Protege可以工作。 但是我想要我的个人
public class Pizza00 {
public static void main(String[] args) throws IOException{
String SOURCE = "http://www.seaice.com/ontologies/seaice.owl";
String NS = SOURCE + "#";
OntModel m = ModelFactory.createOntologyModel();
try {
m.read(new FileInputStream("G:/Protege/owl files/SeaIce.owl"), null);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
reason rec = new reason();
rec = readFileByLines("G:/data/seaice_property.txt");
int i;
OntClass tmp = m.getOntClass(NS + "SeaIceProperty");
for(i = 1; i <= rec.line - 1; i ++){
m.createIndividual(NS + rec.s[i], tmp);
}
m.write(System.out);
OutputStream out = new FileOutputStream("G:/Protege/owl files/SeaIce - by jena.owl");
m.write(out, "RDF/XML-ABBREV", null);
out.close();
}
static class reason{
String[] s= new String[1000];
int line;
}
public static reason readFileByLines(String fileName) {
File file = new File(fileName);
BufferedReader reader = null;
reason x = new reason();
try {
reader = new BufferedReader(new FileReader(file));
String tempString = null;
// 一次读入一行,直到读入null为文件结束
while ((tempString = reader.readLine()) != null) {
// 显示行号
x.s[x.line] = tempString;
x.line++;
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
return x;
}
公共类披萨00{
公共静态void main(字符串[]args)引发IOException{
字符串源=”http://www.seaice.com/ontologies/seaice.owl";
字符串NS=源+“#”;
OntModel m=ModelFactory.createOntologyModel();
试一试{
m、 读取(新文件输入流(“G:/Protege/owl files/SeaIce.owl”),null;
}捕获(FileNotFoundException e1){
e1.printStackTrace();
}
原因记录=新原因();
rec=readfilebyline(“G:/data/seaice_property.txt”);
int i;
OntClass tmp=m.getOntClass(NS+“SeaIceProperty”);
对于(i=1;i,正如您在评论中提到的,错误为
此行
发生错误
Protege的错误是
org.semanticweb.owlapi.rdf.syntax.RDFParserException:
[line=30:column=101]IRI'seaice.com/ontologys/seaice.owl#Optical
“波段图像”无法根据当前的基本IRI进行解析
文件:/G:/Protege/owl%20files/SeaIce%20-%20by%20jena.owl
不完全的IRIseaice.com/ontologys/seaice.owl#Optical Band images
是相对的,无法与当前的基础IRI进行解析,基础IRI是一个文件IRI:file:/G:/Protege/owl%20files/seaice%20-%20by%20jena.owl
。最简单的解决方法是在创建命名个体时使用绝对IRI。发生s行错误。Protege的错误为org.semanticweb.owlapi.rdf.syntax.RDFParserException:[line=30:column=101]IRI“波段图像”无法通过当前的基础IRI文件解决:/G:/Protege/owl%20files/SeaIce%20-%20by%20jena.owl非常感谢您的帮助。我看到您回答了很多Protege和Jena的问题,我想您一定很有效率。我按照您的建议做了,但没有成功。结果是原因是我的I的名字个体包含空间。