每次使用相同的RDF进行反序列化时,使用Jena反序列化包含空白节点的RDF会导致这些节点的唯一ID。如果多次反序列化相同的RDF并合并,则空白节点将重复。有没有办法避免或删除重复?
static final String RDF =
"<http://www.foo.com/subject>" +
"<http://www.foo.com/predicate>" +
"[ a <http://www.foo.com/bar> , <http://www.foo.com/baz> ] .";
public static void main(String... args) {
Model m1 = ModelFactory.createDefaultModel().read(new StringReader(RDF), null, "ttl");
Model m2 = ModelFactory.createDefaultModel().read(new StringReader(RDF), null, "ttl");
Model m3 = m1.union(m2);
RDFDataMgr.write(System.out, m3, Lang.TURTLE);
}
//<http://www.foo.com/subject>
// <http://www.foo.com/predicate> [ a <http://www.foo.com/bar> , <http://www.foo.com/baz> ] ;
// <http://www.foo.com/predicate> [ a <http://www.foo.com/bar> , <http://www.foo.com/baz> ] .
这个人为的例子有点傻,但考虑到我正在尝试合并可能相同或不相同的RDF文件。