Java Code Examples for com.hp.hpl.jena.query.Dataset#listNames()
The following examples show how to use
com.hp.hpl.jena.query.Dataset#listNames() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TrigUtil.java From EventCoreference with Apache License 2.0 | 6 votes |
static public ArrayList<String> getAllEntityEvents (Dataset dataset, String entity) { ArrayList<String> events = new ArrayList<String>(); Iterator<String> it = dataset.listNames(); while (it.hasNext()) { String name = it.next(); if (!name.equals(instanceGraph) && (!name.equals(provenanceGraph))) { Model namedModel = dataset.getNamedModel(name); StmtIterator siter = namedModel.listStatements(); while (siter.hasNext()) { Statement s = siter.nextStatement(); String object = getObjectValue(s).toLowerCase(); if (object.indexOf(entity.toLowerCase()) > -1) { String subject = s.getSubject().getURI(); if (!events.contains(subject)) { events.add(subject); } } } } } return events; }
Example 2
Source File: WriteStatementsKnowledgeStore.java From EventCoreference with Apache License 2.0 | 5 votes |
static public void main (String[] args) { Dataset dataset = null; String address = "http://145.100.57.176:50053/"; ArrayList<org.openrdf.model.Statement> statements = new ArrayList<org.openrdf.model.Statement>(); Iterator<String> it = dataset.listNames(); while (it.hasNext()) { String name = it.next(); Model namedModel = dataset.getNamedModel(name); StmtIterator siter = namedModel.listStatements(); while (siter.hasNext()) { com.hp.hpl.jena.rdf.model.Statement s = siter.nextStatement(); org.openrdf.model.Statement statement =castJenaOpenRdf(s, name); if (statement!=null) { statements.add(statement); } } } if (DEBUG) { try { ByteArrayOutputStream os = new ByteArrayOutputStream(); RDFDataMgr.write(os, dataset, RDFFormat.TRIG_PRETTY); String rdfString = new String(os.toByteArray(), "UTF-8"); System.out.println("rdfString = " + rdfString); os.close(); } catch (Exception e) { e.printStackTrace(); } } // System.out.println("address = " + address); WriteStatementsKnowledgeStore.storeTriples(statements, address); }
Example 3
Source File: GetEventStats.java From EventCoreference with Apache License 2.0 | 5 votes |
static ArrayList<String> getAllEsoEvents (Dataset dataset, ArrayList<String> esoTypes) { ArrayList<String> events = new ArrayList<String>(); Iterator<String> it = dataset.listNames(); while (it.hasNext()) { String name = it.next(); if (name.equals(instanceGraph)) { Model namedModel = dataset.getNamedModel(name); StmtIterator siter = namedModel.listStatements(); while (siter.hasNext()) { Statement s = siter.nextStatement(); // System.out.println("s.toString() = " + s.toString()); if (s.getPredicate().toString().endsWith("#type")) { for (int i = 0; i < esoTypes.size(); i++) { String esoType = esoTypes.get(i); if (s.getObject().toString().endsWith(esoType)) { String subject = s.getSubject().getURI(); if (!events.contains(subject)) { events.add(subject); } break; } } } } } } return events; }