我在編譯過程中遇到了問題。你能幫忙解決問題嗎?`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數(shù)據(jù)合并
1 回答

慕田峪4524236
TA貢獻(xiàn)1875條經(jīng)驗 獲得超5個贊
您正在循環(huán)訪問對象,這些對象是 RDF 語句的 Java 表示形式,或“三元組”。它有一個主語(可通過)、謂詞 () 和一個賓語 ()。請參閱 https://rdf4j.eclipse.org/documentation/getting-started/ 更詳細(xì)的介紹。StatementStatement.getSubject()Statement.getPredicate()Statement.getObject()
例如,如果要刪除所有以 IRI 為對象的三元組,可以執(zhí)行如下操作: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
提交
取消