You haven't actually put any triples into model.
If you want to read from the web, then do:
RDFDataMgr.read(model, uri) ;
model.createResource(uri); just creates a local object for the URI - it
does not fetch data.
Andy
On 10/11/13 14:28, Luciane Monteiro wrote:
*Yes, I did this: ( Here response is a List<DBpediaResource> )*
Model model = ModelFactory.createDefaultModel();
List<String> uriList = new ArrayList<String>();
for( DBpediaResource dbResource : response ) {
String uri = dbResource.getFullUri();
uriList.add(uri);
}
for( String uri : uriList ) {
Resource resource = model.createResource(uri);
StmtIterator stmts = resource.listProperties(RDFS.comment);
while( stmts.hasNext() ) {
Statement stmt = stmts.next();
RDFNode comment = stmt.getObject();
* System.out.println("Comment: " + comment.toString());*
}
}
*But when I try to print the Comment it returns me nothing. Is there
anything wrong?*
2013/11/9 Joshua TAYLOR <[email protected]>
On Fri, Nov 8, 2013 at 12:23 PM, Luciane Monteiro <[email protected]>
wrote:
Hi!
I need to dereference *URIs*, like:
http://dbpedia.org/resource/Google
and
http://dbpedia.org/resource/American_Airlines
returned from *Spotlight*, to get their *RDFS:comments* property.
Is it something like this? Look:
Model model = ModelFactory.createDefaultModel();
model.read( "http://dbpedia.org/resource/Google" );
But how do I get the property?
When you asked this on the DBpedia mailing list, I did include code in
my response, in addition to pointing you to the Jena mailing list. As
Andy Seaborne mentioned, the Model API (particularly the Model and
Resource interfaces) will help you out here:
Resource google = model.createResource( "
http://dbpedia.org/resource/Google" );
StmtIterator stmts = google.listProperties( RDFS.comment );
while ( stmts.hasNext() ) {
Statement stmt = stmts.next();
RDFNode comment = stmt.getObject();
/* do something with the comment */
}
--
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/