com.hp.hpl.jena.query.Dataset Java Examples
The following examples show how to use
com.hp.hpl.jena.query.Dataset.
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: GetPerspectiveRelations.java From EventCoreference with Apache License 2.0 | 6 votes |
public static void perspectiveRelationsToTrig (String pathToTrigFile, ArrayList<PerspectiveObject> perspectiveObjects) { try { OutputStream fos = new FileOutputStream(pathToTrigFile); Dataset ds = TDBFactory.createDataset(); Model defaultModel = ds.getDefaultModel(); //ResourcesUri.prefixModel(defaultModel); // Model provenanceModel = ds.getNamedModel("http://www.newsreader-project.eu/perspective"); ResourcesUri.prefixModelGaf(defaultModel); String attrBase = pathToTrigFile+"_"; JenaSerialization.addJenaPerspectiveObjects(attrBase, ResourcesUri.grasp, "wasAttributedTo", perspectiveObjects, 1); RDFDataMgr.write(fos, ds, RDFFormat.TRIG_PRETTY); fos.close(); } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } }
Example #2
Source File: RDFFileManager.java From Benchmark with GNU General Public License v3.0 | 6 votes |
private static Map<String, EventDeclaration> extractEDsFromDataset(Dataset dataset) { // List<EventDeclaration> eds = new ArrayList<EventDeclaration>(); String describeStr = queryPrefix + " select ?x" + " where{?x rdf:type ?y graph <http://www.insight-centre.org/ces#> { ?y rdfs:subClassOf ces:EventService}}"; // Query query = QueryFactory.create(describeStr); // query.setPrefixMapping(pmap); QueryExecution qe = QueryExecutionFactory.create(describeStr, dataset); ResultSet results = qe.execSelect(); // ResultSetFormatter.out(System.out, results, query); Map<String, EventDeclaration> edMap = new HashMap<String, EventDeclaration>(); while (results.hasNext()) { QuerySolution row = results.next(); RDFNode edID = row.get("x"); // System.out.println("has id: " + edID.toString()); extractEDByServiceID(edID, dataset, edMap); } // RDFDataMgr.write(System.out, results, Lang.TURTLE); return edMap; }
Example #3
Source File: RDFFileManager.java From Benchmark with GNU General Public License v3.0 | 6 votes |
private static String extractFoIById(Dataset dataset, String foiId) { String queryStr = queryPrefix + " select ?a ?b ?c ?d where { <" + foiId + "> ct:hasStartLatitude ?a. <" + foiId + "> ct:hasStartLongitude ?b. <" + foiId + "> ct:hasEndLatitude ?c. <" + foiId + "> ct:hasEndLongitude ?d.}"; QueryExecution qe = QueryExecutionFactory.create(queryStr, dataset); ResultSet results = qe.execSelect(); if (results.hasNext()) { // RDFNode foi = results.next().get("y"); QuerySolution qs = results.next(); Double startLat = qs.getLiteral("a").getDouble(); Double startLon = qs.getLiteral("b").getDouble(); Double endLat = qs.getLiteral("c").getDouble(); Double endLon = qs.getLiteral("d").getDouble(); return startLat + "," + startLon + "-" + endLat + "," + endLon; // ed.setFoi(startLat + "," + startLon + "-" + endLat + "," + endLon); // } } return null; }
Example #4
Source File: RDFFileManager.java From Benchmark with GNU General Public License v3.0 | 6 votes |
private static void extractEventPattern(EventDeclaration ed, Dataset dataset, Map<String, EventDeclaration> edMap) throws CloneNotSupportedException { String desribeStr = queryPrefix + " describe ?z where {<" + ed.getnodeId() + "> owls:presents ?y. ?y ces:hasPattern ?z.}"; QueryExecution qe1 = QueryExecutionFactory.create(desribeStr, dataset); Model patternModel = qe1.execDescribe(); // RDFDataMgr.write(System.out, patternModel, Lang.TURTLE); EventPattern ep = new EventPattern(); ep.setID("EP-" + ed.getnodeId()); // ep.setFilters(new HashMap<String, List<Filter>>()); String queryRoot = queryPrefix + " select ?z where {<" + ed.getnodeId() + "> owls:presents ?y. ?y ces:hasPattern ?z.}"; QueryExecution qe2 = QueryExecutionFactory.create(queryRoot, dataset); ResultSet results = qe2.execSelect(); if (results.hasNext()) { ed.setEp(ep); RDFNode root = results.next().get("z"); traverseToExtract(0, root, patternModel, ep, dataset, edMap); extractSelectionMap(root, patternModel, ep, dataset, edMap); // System.out.println("EP extracted: " + ep.toString()); } // traverse // RDFDataMgr.write(System.out, results, Lang.TURTLE); }
Example #5
Source File: RDFFileManager.java From Benchmark with GNU General Public License v3.0 | 6 votes |
private static String extractEventPayloads(EventDeclaration ed, Dataset dataset) { String queryStr = queryPrefix + " select ?x ?y ?z where {<" + ed.getnodeId() + "> ssn:observes ?x. ?x rdf:type ?y. ?x ssn:isPropertyOf ?z }"; QueryExecution qe = QueryExecutionFactory.create(queryStr, dataset); ResultSet results = qe.execSelect(); List<String> payloads = new ArrayList<String>(); String foiId = ""; while (results.hasNext()) { QuerySolution result = results.next(); RDFNode propertyName = result.get("x"); RDFNode propertyType = result.get("y"); RDFNode foi = result.get("z"); if (propertyType.toString().equals("http://www.w3.org/2000/01/rdf-schema#Resource")) continue; // System.out.println("type: " + property + " foi: " + foi); payloads.add(propertyType.toString() + "|" + foi.toString() + "|" + propertyName.toString()); foiId = foi.toString(); // System.out.println("payload: " + propertyType.toString() + "|" + foi.toString() + "|" // + propertyName.toString()); } ed.setPayloads(payloads); return foiId; }
Example #6
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 #7
Source File: FromAndFromNamedClauses_ITCase.java From SolRDF with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { Dataset memoryDataset = DatasetFactory.createMem(); Model memoryModel = ModelFactory.createDefaultModel(); memoryModel.read(new FileReader("/work/workspaces/rdf/SolRDF/solrdf/src/test/resources/sample_data/one_triple_1.ttl"), "http://e.org", "TTL"); memoryDataset.addNamedModel("http://grapha.com", memoryModel); memoryModel = ModelFactory.createDefaultModel(); memoryModel.read(new FileReader("/work/workspaces/rdf/SolRDF/solrdf/src/test/resources/sample_data/one_triple_2.ttl"), "http://e.org", "TTL"); memoryDataset.addNamedModel("http://graphb.com", memoryModel); memoryModel = ModelFactory.createDefaultModel(); memoryModel.read(new FileReader("/work/workspaces/rdf/SolRDF/solrdf/src/test/resources/sample_data/one_triple_3.ttl"), "http://e.org", "TTL"); memoryDataset.addNamedModel("http://graphc.com", memoryModel); memoryModel = ModelFactory.createDefaultModel(); memoryModel.read(new FileReader("/work/workspaces/rdf/SolRDF/solrdf/src/test/resources/sample_data/one_triple_4.ttl"), "http://e.org", "TTL"); memoryDataset.addNamedModel("http://graphd.com", memoryModel); final Query query = QueryFactory.create(q2());//"SELECT ?s FROM <http://grapha.com> WHERE { ?s <http://example.org/title> ?o }"); System.out.println(ResultSetFormatter.asText(QueryExecutionFactory.create(query, memoryDataset).execSelect())); }
Example #8
Source File: RDFFileManager.java From Benchmark with GNU General Public License v3.0 | 5 votes |
private static void extractEventSource(EventDeclaration ed, Dataset dataset) { ed.setServiceId(ed.getnodeId()); String queryStr = queryPrefix + " select ?z where {<" + ed.getnodeId() + "> owls:supports ?y. ?y ces:httpService ?z.}"; QueryExecution qe = QueryExecutionFactory.create(queryStr, dataset); ResultSet results = qe.execSelect(); if (results.hasNext()) { RDFNode addr = results.next().get("z"); ed.setSrc(addr.toString()); // System.out.println("addr: " + addr); } }
Example #9
Source File: GetPerspectiveRelations.java From EventCoreference with Apache License 2.0 | 5 votes |
public static void perspectiveRelationsToTrig (String pathToTrigFile, KafSaxParser kafSaxParser, String project, ArrayList<PerspectiveObject> sourcePerspectiveObjects, ArrayList<PerspectiveObject> authorPerspectiveObjects) { try { OutputStream fos = new FileOutputStream(pathToTrigFile); Dataset ds = TDBFactory.createDataset(); Model defaultModel = ds.getDefaultModel(); ResourcesUri.prefixModelGaf(defaultModel); ResourcesUri.prefixModelNwr(defaultModel); defaultModel.setNsPrefix("rdf", ResourcesUri.rdf); defaultModel.setNsPrefix("rdfs", ResourcesUri.rdfs); String docId = kafSaxParser.getKafMetaData().getUrl().replaceAll("#", "HASH"); if (!docId.toLowerCase().startsWith("http")) { docId = ResourcesUri.nwrdata + project + "/" + docId; } JenaSerialization.addDocMetaData(docId, kafSaxParser, project); String attrBase = kafSaxParser.getKafMetaData().getUrl()+"_"+"s"; JenaSerialization.addJenaPerspectiveObjects(attrBase, ResourcesUri.grasp, "wasAttributedTo", sourcePerspectiveObjects, 1); attrBase = kafSaxParser.getKafMetaData().getUrl()+"_"+"d"; JenaSerialization.addJenaPerspectiveObjects(attrBase, ResourcesUri.prov, "wasDerivedFrom", authorPerspectiveObjects, sourcePerspectiveObjects.size()+1); RDFDataMgr.write(fos, ds, RDFFormat.TRIG_PRETTY); fos.close(); } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } }
Example #10
Source File: SemRelation.java From EventCoreference with Apache License 2.0 | 5 votes |
public void addToJenaDataSetSimple (HashMap<String, String> rename, Dataset ds) { Model relationModel = ds.getNamedModel(this.id); if (rename.containsKey(this.getSubject())) { this.setSubject(rename.get(this.getSubject())); } if (rename.containsKey(this.getObject())) { this.setObject(rename.get(this.getObject())); } Resource subject = relationModel.createResource(this.getSubject()); Resource object = relationModel.createResource(this.getObject()); /// since we no longer distinguish places from actors, we now check the predicates for propbank AM-LOC /// if so we use sem:hasPlace otherwise we take the semType value from the hasSem predicate Property semProperty = null; for (int i = 0; i < predicates.size(); i++) { String predicate = predicates.get(i); semProperty = getSemRelationProperty(predicate); if (isTemporalSemRelationProperty(predicate)) { subject.addProperty(semProperty, object); } else { if (!semProperty.getLocalName().equals(Sem.hasActor.getLocalName()) && !semProperty.getLocalName().equals(Sem.hasPlace.getLocalName())) { predicate = getSimpleRoleRelation(predicate); //System.err.println("predicate:"+predicate); //predicate = getFramenetRoleRelation(predicates.get(i)); if (!predicate.isEmpty()) { Property srlProperty = relationModel.createProperty(predicate); subject.addProperty(srlProperty, object); } } } } }
Example #11
Source File: GetPerspectiveRelations.java From EventCoreference with Apache License 2.0 | 5 votes |
public static void perspectiveRelationsToTrigStream (OutputStream fos, String uri, ArrayList<PerspectiveObject> perspectiveObjects) { Dataset ds = TDBFactory.createDataset(); Model defaultModel = ds.getDefaultModel(); ResourcesUri.prefixModel(defaultModel); // Model provenanceModel = ds.getNamedModel("http://www.newsreader-project.eu/perspective"); ResourcesUri.prefixModelGaf(defaultModel); String attrBase = uri+"_"; JenaSerialization.addJenaPerspectiveObjects(attrBase, ResourcesUri.grasp,"wasAttributedTo", perspectiveObjects, 1); RDFDataMgr.write(fos, ds, RDFFormat.TRIG_PRETTY); }
Example #12
Source File: QueryResultTableImpl.java From semweb4j with BSD 2-Clause "Simplified" License | 5 votes |
public QueryResultTableImpl(Query query, Dataset jenaDataset) throws ModelRuntimeException { if(!query.isSelectType()) { throw new ModelRuntimeException("The given query is not a SELECT query"); } // else this.varnames = new ArrayList<String>(); for(Object o : query.getResultVars()) { this.varnames.add((String)o); } this.qexec = QueryExecutionFactory.create(query, jenaDataset); }
Example #13
Source File: RDFFileManager.java From Benchmark with GNU General Public License v3.0 | 5 votes |
private static void loadOntology(Dataset dataset) { Model ssnBase = FileManager.get().loadModel(ontologyDirectory + "ssn.owl"); Model ssnInf = ModelFactory.createOntologyModel(ontoSpec, ssnBase); dataset.addNamedModel(ssnPrefix, ssnInf); Model owlService = FileManager.get().loadModel(ontologyDirectory + "Service.owl"); Model owlServiceInf = ModelFactory.createOntologyModel(ontoSpec, owlService); dataset.addNamedModel(owlsPrefix, owlServiceInf); Model owlGrounding = FileManager.get().loadModel(ontologyDirectory + "Grounding.owl"); Model owlGroundingInf = ModelFactory.createOntologyModel(ontoSpec, owlGrounding); dataset.addNamedModel(owlsPrefix, owlGroundingInf); Model owlProcess = FileManager.get().loadModel(ontologyDirectory + "Process.owl"); Model owlProcessInf = ModelFactory.createOntologyModel(ontoSpec, owlProcess); dataset.addNamedModel(owlsPrefix, owlProcessInf); Model owlProfile = FileManager.get().loadModel(ontologyDirectory + "Profile.owl"); Model owlProfileInf = ModelFactory.createOntologyModel(ontoSpec, owlProfile); dataset.addNamedModel(owlsPrefix, owlProfileInf); Model cesBase = FileManager.get().loadModel(ontologyDirectory + "ces.n3"); Model cesInf = ModelFactory.createOntologyModel(ontoSpec, cesBase); dataset.addNamedModel(cesPrefix, cesInf); Model ctBase = FileManager.get().loadModel(ontologyDirectory + "city.n3"); Model ctInf = ModelFactory.createOntologyModel(ontoSpec, ctBase); dataset.addNamedModel(ctPrefix, ctInf); // FileManager.get().r(dataset.getNamedModel(ssnPrefix), // ModelFactory.createInfModel(ReasonerRegistry.getRDFSReasoner(), ssnBase)); // FileManager.get().readModel(dataset.getNamedModel(owlPrefix), ontologyDirectory + "Service.owl"); // // FileManager.get().readModel(dataset.getNamedModel(owlPrefix), ontologyDirectory + "Grounding.owl"); // FileManager.get().readModel(dataset.getNamedModel(owlPrefix), ontologyDirectory + "Process.owl"); // FileManager.get().readModel(dataset.getNamedModel(owlPrefix), ontologyDirectory + "Profile.owl"); // FileManager.get().readModel(dataset.getNamedModel(cesPrefix), ontologyDirectory + "ces.n3"); }
Example #14
Source File: RDFFileManager.java From Benchmark with GNU General Public License v3.0 | 5 votes |
public static Dataset initializeCSPARQLContext(String serviceDesc, Reasoner r) { // ExecContext context; // if (r != null) // context = new ReasonerContext(cqelsHome, true, ReasonerRegistry.getRDFSReasoner()); // else // context = new ExecContext(cqelsHome, true); Model defaultModel = FileManager.get().loadModel(datasetDirectory + serviceDesc); Model ces = FileManager.get().loadModel(ontologyDirectory + "ces.n3"); dataset = DatasetFactory.create(defaultModel); dataset.addNamedModel(cesPrefix, ces); return dataset; }
Example #15
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 #16
Source File: RDFFileManager.java From Benchmark with GNU General Public License v3.0 | 5 votes |
private static String extractEventType(String edID, Dataset dataset) { String queryStr = queryPrefix + " select ?name where {<" + edID + "> owls:presents ?profile. ?profile owlssc:serviceCategory ?z. ?z owlssc:serviceCategoryName ?name}"; QueryExecution qe = QueryExecutionFactory.create(queryStr, dataset); ResultSet results = qe.execSelect(); String type = ""; if (results.hasNext()) { Literal l = results.next().getLiteral("name"); type = l.getString(); } return type; }
Example #17
Source File: RDFFileManager.java From Benchmark with GNU General Public License v3.0 | 5 votes |
private static void extractEventFoIAsResource(EventDeclaration ed, Dataset dataset, String foiId) { // if (ed instanceof TrafficReportService) { // extractTrafficLocation(ed, dataset); // } else { String queryStr = queryPrefix + " select ?foi where { <" + ed.getServiceId() + "> ssn:observes ?p. ?p ssn:isPropertyOf ?foi.}"; QueryExecution qe = QueryExecutionFactory.create(queryStr, dataset); ResultSet results = qe.execSelect(); if (results.hasNext()) { RDFNode foi = results.next().get("foi"); ed.setFoi(foi.toString()); // } } }
Example #18
Source File: RDFFileManager.java From Benchmark with GNU General Public License v3.0 | 5 votes |
private static void extractEventFoI(EventDeclaration ed, Dataset dataset, String foiId) { // if (ed instanceof TrafficReportService) { // extractTrafficLocation(ed, dataset); // } else { String foiStr = extractFoIById(dataset, foiId); if (foiStr != null) ed.setFoi(foiStr); else extractEventFoIAsResource(ed, dataset, foiId); // for (String payload : ed.getPayloads()) // payload = payload.replace(foiId, foiStr); }
Example #19
Source File: RDFFileManager.java From Benchmark with GNU General Public License v3.0 | 5 votes |
private static EventDeclaration extractEDByServiceID(RDFNode edID, Dataset dataset, Map<String, EventDeclaration> edMap) { if (!edMap.containsKey(edID)) { EventDeclaration ed; String type = extractEventType(edID.toString(), dataset); if (type.equals("traffic_report")) { ed = new TrafficReportService(edID.toString(), "", type, null, null, null); // extractTrafficLocation(ed, dataset); } else ed = new EventDeclaration(edID.toString(), "", type, null, null, null, null); extractEventSource(ed, dataset); String foiId = extractEventPayloads(ed, dataset); extractEventQoS(ed, dataset); extractEventFoI(ed, dataset, foiId); // extractEventFoIAsResource(ed, dataset, foiId); try { extractEventPattern(ed, dataset, edMap); } catch (CloneNotSupportedException e) { System.out.println("ACEIS IO: Pattern extraction failed."); e.printStackTrace(); } edMap.put(edID.toString(), ed); // System.out.println("Extracting: " + ed.toString() + " serviceId: " + ed.getServiceId()); return ed; } return edMap.get(edID); }
Example #20
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; }
Example #21
Source File: RDFFileManager.java From Benchmark with GNU General Public License v3.0 | 4 votes |
private static void extractTrafficLocation(EventDeclaration ed, Dataset dataset) { // String queryStr = queryPrefix // + " select ?rid ?fnn ?fnsn ?fnst ?fnc ?fnlat ?fnlon ?snn ?snsn ?snst ?snc ?snlat ?snlon where {<" // + ed.getID() // + "> owls:presents ?profile. <" // + ed.getID() // + // "> ssn:observes ?y. ?profile ct:hasReportID ?rid. ?y ssn:isPropertyOf ?z. ?z ct:hasFirstNode ?fn. ?z ct:hasSecondNode ?sn. " // + // " ?fn ct:hasNodeName ?fnn. ?fn ct:hasStreetNumber ?fnsn. ?fn ct:hasStreet ?fnst. ?fn ct:hasCity ?fnc. ?fn ct:hasLatitude ?fnlat. ?fn ct:hasLongtitude ?fnlon." // + // " ?sn ct:hasNodeName ?snn. ?sn ct:hasStreetNumber ?snsn. ?sn ct:hasStreet ?snst. ?sn ct:hasCity ?snc. ?sn ct:hasLatitude ?snlat. ?sn ct:hasLongtitude ?snlon.}"; String queryStr = queryPrefix + " select ?z where { <" + ed.getnodeId() + "> ssn:observes ?y. ?y ssn:isPropertyOf ?z.} "; // + // " ?fn ct:hasNodeName ?fnn. ?fn ct:hasStreetNumber ?fnsn. ?fn ct:hasStreet ?fnst. ?fn ct:hasCity ?fnc. ?fn ct:hasLatitude ?fnlat. ?fn ct:hasLongtitude ?fnlon." // + // " ?sn ct:hasNodeName ?snn. ?sn ct:hasStreetNumber ?snsn. ?sn ct:hasStreet ?snst. ?sn ct:hasCity ?snc. ?sn ct:hasLatitude ?snlat. ?sn ct:hasLongtitude ?snlon.}"; QueryExecution qe = QueryExecutionFactory.create(queryStr, dataset); ResultSet results = qe.execSelect(); if (results.hasNext()) { QuerySolution row = results.next(); String foiStr = row.get("z").toString(); // String reportId = row.get("rid").asLiteral().getString(); // String firstNodeName = row.get("fnn").asLiteral().getString(); // String firstNodeStreetNo = row.get("fnsn").asLiteral().getString(); // String firstNodeStreet = row.get("fnst").asLiteral().getString(); // String firstNodeCity = row.get("fnc").asLiteral().getString(); // Double firstNodeLat = row.get("fnlat").asLiteral().getDouble(); // Double firstNodeLon = row.get("fnlon").asLiteral().getDouble(); // // String secondNodeName = row.get("snn").asLiteral().getString(); // String secondNodeStreetNo = row.get("snsn").asLiteral().getString(); // String secondNodeStreet = row.get("snst").asLiteral().getString(); // String secondNodeCity = row.get("snc").asLiteral().getString(); // Double secondNodeLat = row.get("snlat").asLiteral().getDouble(); // Double secondNodeLon = row.get("snlon").asLiteral().getDouble(); // ((TrafficReportService) ed).setReportId(reportId); // ((TrafficReportService) ed).setNode1City(firstNodeCity); // ((TrafficReportService) ed).setNode1Lat(firstNodeLat); // ((TrafficReportService) ed).setNode1Lon(firstNodeLon); // ((TrafficReportService) ed).setNode1Street(firstNodeStreet); // ((TrafficReportService) ed).setNode1StreetNo(firstNodeStreetNo); // ((TrafficReportService) ed).setNode1Name(firstNodeName); // ((TrafficReportService) ed).setNode2City(secondNodeCity); // ((TrafficReportService) ed).setNode2Lat(secondNodeLat); // ((TrafficReportService) ed).setNode2Lon(secondNodeLon); // ((TrafficReportService) ed).setNode2Name(secondNodeName); // ((TrafficReportService) ed).setNode2Street(secondNodeStreet); // ((TrafficReportService) ed).setNode2StreetNo(secondNodeStreetNo); ed.setFoi(foiStr); } }
Example #22
Source File: SemRelation.java From EventCoreference with Apache License 2.0 | 4 votes |
public void addToJenaDataSet (Dataset ds, Model provenanceModel) { Model relationModel = ds.getNamedModel(this.id); Resource subject = relationModel.createResource(this.getSubject()); Resource object = relationModel.createResource(this.getObject()); /// since we no longer distinguish places from actors, we now check the predicates for propbank AM-LOC /// if so we use sem:hasPlace otherwise we take the semType value from the hassem predicate Property semProperty = null; boolean PLACE = false; boolean ACTOR = false; for (int i = 0; i < predicates.size(); i++) { String predicate = predicates.get(i); if (predicate.equalsIgnoreCase("hasFactBankValue")) { Property factProperty = relationModel.createProperty(ResourcesUri.nwrvalue + predicate); subject.addProperty(factProperty, this.getObject()); /// creates the literal as value }else { semProperty = getSemRelationProperty(predicate); if (isTemporalSemRelationProperty(predicate)) { subject.addProperty(semProperty, object); subject.addProperty(Sem.hasTime, object); /// additional hasTime relation to generalize } else { if (!semProperty.getLocalName().equals(Sem.hasActor.getLocalName()) && !semProperty.getLocalName().equals(Sem.hasPlace.getLocalName())) { predicate = getRoleRelation(predicate); if (!predicate.isEmpty()) { Property srlProperty = relationModel.createProperty(predicate); subject.addProperty(srlProperty, object); String predicateValue = predicate; int idx = predicateValue.lastIndexOf("/"); if (idx > -1) predicateValue = predicateValue.substring(idx + 1); if (RoleLabels.isLOCATION(predicateValue)) { PLACE = true; } else { ACTOR = true; } } } } } } //// if at the end of the loop we detected a location role if (PLACE) { subject.addProperty(Sem.hasPlace, object); } //// if at the end of the loop we detect an actor role if (ACTOR) { subject.addProperty(Sem.hasActor, object); } Resource provenanceResource = provenanceModel.createResource(this.id); for (int i = 0; i < nafMentions.size(); i++) { NafMention nafMention = nafMentions.get(i); Property property = provenanceModel.createProperty(ResourcesUri.gaf+"denotedBy"); Resource targetResource = provenanceModel.createResource(nafMention.toString()); provenanceResource.addProperty(property, targetResource); } }
Example #23
Source File: D2RQDatasetDesc.java From GeoTriples with Apache License 2.0 | 4 votes |
@Override public Dataset acquireDataset(Request request, Response response) { dataset.checkMappingFileChanged(); return this.dataset; }
Example #24
Source File: RDFFileManager.java From Benchmark with GNU General Public License v3.0 | 4 votes |
private static void extractEventQoS(EventDeclaration ed, Dataset dataset) { // TODO change quality prefix String queryStr = queryPrefix + " select ?type ?value where {<" + ed.getnodeId() + "> owls:presents ?profile. ?profile ?hasnfp ?x. ?x rdf:type ?type. ?x owlssp:sParameter ?y. ?y emvo:hasQuantityValue ?value " + " graph <http://www.insight-centre.org/ces#> {?hasnfp rdfs:subPropertyOf owlssp:serviceParameter}}"; // String queryStr = queryPrefix // + // " select ?srvId ?type ?value where {?srvId owls:presents ?profile. ?profile ?hasnfp ?x. ?x rdf:type ?type. ?x owlssp:sParameter ?y. ?y emvo:hasQuantityValue ?value }"; long t1 = System.currentTimeMillis(); // String queryStr = queryPrefix // + "select ?srvId ?srvCatName ?pType ?foiId ?a ?b ?c ?d ?qType ?qValue where { " // + // "?srvId owls:presents ?profile. ?profile owlssc:serviceCategory ?srvCat. ?srvCat owlssc:serviceCategoryName " // + "?srvCatName. ?srvId ssn:observes ?pid. ?pid rdf:type ?pType. ?pid ssn:isPropertyOf ?foiId. " // + "?foiId ct:hasStartLatitude ?a. ?foiId ct:hasStartLongitude ?b. ?foiId ct:hasEndLatitude ?c. " // + "?foiId ct:hasEndLongitude ?d. OPTIONAL {?srvId owls:presents ?profile. ?profile ?hasnfp ?x. " // + "?x rdf:type ?qType. ?x owlssp:sParameter ?y. ?y emvo:hasQuantityValue ?qValue " // + "graph <http://www.insight-centre.org/ces#> {?hasnfp rdfs:subPropertyOf ces:hasNFP}}}"; QueryExecution qe = QueryExecutionFactory.create(queryStr, dataset); ResultSet results = qe.execSelect(); QosVector qos = new QosVector(); boolean hasQos = false; int sum = 0; while (results.hasNext()) { sum++; hasQos = true; QuerySolution row = results.next(); RDFNode type = row.get("type"); RDFNode value = row.get("value"); // type. // ed.setSrc(addr.toString()); // System.out.println("type: " + type + "\n value: " + value); if (type.toString().equals("http://www.insight-centre.org/ces#Security")) qos.setSecurity(value.asLiteral().getInt()); else if (type.toString().equals("http://www.insight-centre.org/ces#Price")) qos.setPrice(value.asLiteral().getInt()); else if (type.toString().equals("http://www.insight-centre.org/ces#Accuracy")) qos.setAccuracy(value.asLiteral().getDouble()); else if (type.toString().equals("http://www.insight-centre.org/ces#Reliability")) qos.setReliability(value.asLiteral().getDouble()); else if (type.toString().equals("http://www.insight-centre.org/ces#Latency")) qos.setLatency(value.asLiteral().getInt()); else if (type.toString().equals("http://www.insight-centre.org/ces#BandWidthConsumption")) ; else if (type.toString().equals("http://www.insight-centre.org/ces#Availability")) ; else if (type.toString().equals("http://www.insight-centre.org/ces#EnergyConsumption")) ; else if (type.toString().equals("http://www.insight-centre.org/ces#Frequency")) ed.setFrequency(value.asLiteral().getDouble()); } long t2 = System.currentTimeMillis(); // logger.info("QoS extracted: " + qos); if (qos.getAccuracy() != null) ed.setInternalQos(qos); }
Example #25
Source File: D2RQDatasetDesc.java From GeoTriples with Apache License 2.0 | 4 votes |
@Override public void returnDataset(Dataset ds) { // do nothing }