java - Adding blank nodes to a Jena model -
i'm trying populate jena ontology model existing set of triples, of contain blank nodes. want maintain these blank nodes inside new model faithfully can't work out way of adding them jena model.
i have been using:
statement s = resourcefactory.createstatement(subject, predicate, object);
to add new statements model:
private ontmodel model = modelfactory.createontologymodel(); model.add(s);
but allows types subject, predicate, , object; resource subject, property predicate, rdfnode object. none of these types allow adding of blanknode subject or object such through:
node subject = nodefactory.createblanknode(subjectvalue);
any suggestions? i've tried using blanknodes resources , creating resource object breaks become classes , not blank nodes.
any appreciated, been pulling hair out this.
well, if have existing set of triples can read them file using:
ontmodel model = modelfactory.createontologymodel(); model.read(new fileinputstream("data.ttl"), null, "ttl");
this take care of blank nodes, see jena documentation
you can create blank node hand this:
resource subject = model.createresource("s"); property predicate = model.createproperty("p"); resource object = model.createresource(); model.add(subject, predicate, object);
which result in like:
[s, p, aad22737-ce84-4564-a9c5-9bdfd49b55de]
Comments
Post a Comment