我在编译过程中遇到了问题。你能帮忙解决问题吗?`public static void main(String[] args) throws IOException { File dir = new File("C:data\\test"); String[] fileNames = dir.list(); FileWriter outFile = new FileWriter("out.ttl"); RDFWriter writer = org.eclipse.rdf4j.rio.Rio.createWriter(RDFFormat.TURTLE, outFile ); writer.startRDF(); for (String fileName : fileNames) { System.out.println("Reading from " + fileName); File f = new File(dir, fileName); Model data = Rio.parse(new FileInputStream(f), "", RDFFormat.TURTLE); for (Statement st: data) { if ( "efrbroo:F22_Self-Contained_Expression" != null ) { writer.handleStatement(st); } } } writer.endRDF();}`这个问题的最初问题在这里:RDF4J数据合并
1 回答
慕田峪4524236
TA贡献1875条经验 获得超5个赞
您正在循环访问对象,这些对象是 RDF 语句的 Java 表示形式,或“三元组”。它有一个主语(可通过)、谓词 () 和一个宾语 ()。请参阅 https://rdf4j.eclipse.org/documentation/getting-started/ 更详细的介绍。StatementStatement.getSubject()Statement.getPredicate()Statement.getObject()
例如,如果要删除所有以 IRI 为对象的三元组,可以执行如下操作:http://example.org/F22_Self-Contained_Expression
IRI f22SelfContainedExpression = SimpleValueFactory.getInstance().createIRI("http://example.org/F22_Self-Contained_Expression");
...
if (!st.getObject().equals(f22SelfContainedExpression)) {
writer.handleStatement(st);
}
添加回答
举报
0/150
提交
取消