本文整理汇总了Java中com.hp.hpl.jena.query.Syntax类的典型用法代码示例。如果您正苦于以下问题:Java Syntax类的具体用法?Java Syntax怎么用?Java Syntax使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Syntax类属于com.hp.hpl.jena.query包,在下文中一共展示了Syntax类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: expandSubClasses
import com.hp.hpl.jena.query.Syntax; //导入依赖的package包/类
private List<Statement> expandSubClasses(Model model){
List<Statement> stmts = new ArrayList<Statement>();
String sparql = "PREFIX rdfs: <" + RDFS.getURI() + ">"
+ "SELECT DISTINCT ?class ?synonym "
+ "WHERE { "
+ "?class rdfs:subClassOf+ ?subClass . "
+ "?subClass <" + synonym + "> ?synonym"
+ "}";
Query query = QueryFactory.create(sparql, Syntax.syntaxARQ);
QueryExecution queryExecution = QueryExecutionFactory.create(query, model);
ResultSet resultSet = queryExecution.execSelect();
resultSet.forEachRemaining(querySolution -> {
stmts.add(new StatementImpl(querySolution.getResource("class"), synonym, querySolution.getLiteral("synonym")));
});
return stmts;
}
示例2: expandSubProperties
import com.hp.hpl.jena.query.Syntax; //导入依赖的package包/类
private List<Statement> expandSubProperties(Model model){
List<Statement> stmts = new ArrayList<Statement>();
String sparql = "PREFIX rdfs: <" + RDFS.getURI() + ">"
+ "SELECT DISTINCT ?property ?synonym "
+ "WHERE { "
+ "?property rdfs:subPropertyOf+ ?subProperty . "
+ "?subProperty <" + synonym + "> ?synonym"
+ "}";
Query query = QueryFactory.create(sparql, Syntax.syntaxARQ);
QueryExecution queryExecution = QueryExecutionFactory.create(query, model);
ResultSet resultSet = queryExecution.execSelect();
resultSet.forEachRemaining(querySolution -> {
stmts.add(new StatementImpl(querySolution.getResource("property"), synonym, querySolution.getLiteral("synonym")));
});
return stmts;
}
示例3: runQueryButtonActionPerformed
import com.hp.hpl.jena.query.Syntax; //导入依赖的package包/类
private void runQueryButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_runQueryButtonActionPerformed
List<String> lines = null;
try {
lines = Files.readAllLines(queryPath);
} catch (IOException ex) {
Logger.getLogger(Ontogui.class.getName()).log(Level.SEVERE, null,
ex);
}
String queryString = "";
for (String line : lines) {
queryString += line + System.lineSeparator();
}
Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);
queryResultArea.setText("Starting query: "
+ queryPath.toFile().getName() + "\n");
Thread t = new Thread(new QueryProcessor(query, new QueryAreaStream(
queryResultArea), dataset, checkbox1.getState()));
t.start();
}
示例4: runSmellAnalysisButtonActionPerformed
import com.hp.hpl.jena.query.Syntax; //导入依赖的package包/类
private void runSmellAnalysisButtonActionPerformed(
java.awt.event.ActionEvent evt) {// GEN-FIRST:event_runSmellAnalysisButtonActionPerformed
String filename = smellName;
File smellFile = new File(System.getProperty("user.dir")
+ "/sparql/smells/" + filename.replaceAll(" ", "") + ".sparql");
List<String> lines = null;
try {
lines = Files.readAllLines(smellFile.toPath());
} catch (IOException ex) {
Logger.getLogger(Ontogui.class.getName()).log(Level.SEVERE, null,
ex);
}
String queryString = "";
for (String line : lines) {
queryString += line + System.lineSeparator();
}
Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);
queryResultArea.setText("Starting analysis: " + smellName + "\n");
Thread t = new Thread(new QueryProcessor(query, new QueryAreaStream(
queryResultArea), dataset, checkbox1.getState()));
t.start();
}
示例5: runMetricsButtonActionPerformed
import com.hp.hpl.jena.query.Syntax; //导入依赖的package包/类
private void runMetricsButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_runMetricsButtonActionPerformed
String folder = metricName.split(":")[0].toLowerCase();
String filename = metricName.split(":")[1];
File metricFile = new File(System.getProperty("user.dir")
+ "/sparql/metrics/" + folder + "/" + filename + ".sparql");
List<String> lines = null;
try {
lines = Files.readAllLines(metricFile.toPath());
} catch (IOException ex) {
Logger.getLogger(Ontogui.class.getName()).log(Level.SEVERE, null,
ex);
}
String queryString = "";
for (String line : lines) {
queryString += line + System.lineSeparator();
}
Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);
queryResultArea.setText("Starting analysis:" + metricName + "\n");
System.err.println(checkbox1.isEnabled());
Thread t = new Thread(new QueryProcessor(query, new QueryAreaStream(
queryResultArea), dataset, checkbox1.getState()));
t.start();
}
示例6: executeQuery
import com.hp.hpl.jena.query.Syntax; //导入依赖的package包/类
public String executeQuery() {
Query query = QueryFactory.create(this.getQuery(), Syntax.syntaxARQ);
Op op = Algebra.compile(query);
try {
if(new String("internal").equals(this.service)) {
this.results = jenaService.runLocalOp(op);
} else if (new String("external").equals(this.service)) {
this.results = jenaService.runExternalOp(op);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
}
return ("success");
}
示例7: getJob
import com.hp.hpl.jena.query.Syntax; //导入依赖的package包/类
public static void getJob(GraphDatabaseService njgraph)
{
NeoGraph graph = new NeoGraph(njgraph);
Model njmodel = ModelFactory.createModelForGraph(graph);
ST descJob = TemplateLoader.getQueriesGroup().getInstanceOf("getGraph");
String queryASString = Constants.QUERY_PREFIX+ descJob.render();
Query query = QueryFactory.create(queryASString, Syntax.syntaxSPARQL_11);
QueryExecution qexec = QueryExecutionFactory.create(query, njmodel);
ResultSet res = qexec.execSelect();
int count=0;
while(res.hasNext()){
//System.out.println("in while"+count);
QuerySolution sol = res.next();
System.out.println(sol.get("?Z"));
count++;
}
//log.info("Record fetched:"+ count);
System.out.println("Record fetched:"+ count);
}
示例8: getCBD
import com.hp.hpl.jena.query.Syntax; //导入依赖的package包/类
private Model getCBD(String uri, String endpoint, String graph) {
String query = "DESCRIBE <" + uri + ">";
System.out.println(query);
Query sparqlQuery = QueryFactory.create(query, Syntax.syntaxARQ);
QueryExecution qexec = QueryExecutionFactory.sparqlService(
endpoint, sparqlQuery, graph);
Model m2;
try {
m2 = qexec.execDescribe();
} catch (Exception e) {
// the result vector is too large: create empty model
m2 = ModelFactory.createDefaultModel();
}
return m2;
}
示例9: fetchDatasets
import com.hp.hpl.jena.query.Syntax; //导入依赖的package包/类
private ArrayList<Dataset> fetchDatasets() {
String query = "select * where { ?x a <http://rdfs.org/ns/void#Dataset> . " +
"?x <http://rdfs.org/ns/void#uriSpace> ?urispace . " +
"?x <http://www.w3.org/2000/01/rdf-schema#label> ?label } " +
"ORDER BY ?label";
Query sparqlQuery = QueryFactory.create(query, Syntax.syntaxARQ);
QueryExecution qexec = QueryExecutionFactory.sparqlService(endpoint, sparqlQuery, graph);
ResultSet results = qexec.execSelect();
ArrayList<Dataset> arr = new ArrayList<>();
while (results.hasNext()) {
QuerySolution n = results.next();
Resource v = n.getResource("x");
Literal label = n.getLiteral("label");
try { // FIXME wrong URIs (as literals) give an exception
RDFNode uri = n.get("urispace");
arr.add(new Dataset(v.getURI(), label.getString(), uri.toString()));
} catch (ClassCastException e) {
}
}
return arr;
}
示例10: fetchFrameworks
import com.hp.hpl.jena.query.Syntax; //导入依赖的package包/类
private ArrayList<FrameworkVersion> fetchFrameworks() {
String query = "select * where { ?v a <http://www.linklion.org/ontology#LDFrameworkVersion> . ?f a <http://www.linklion.org/ontology#LDFramework> . " +
"?f <http://usefulinc.com/ns/doap#release> ?v . ?f <http://xmlns.com/foaf/0.1/homepage> ?url . " +
"?v <http://www.w3.org/2000/01/rdf-schema#label> ?label . ?v <http://usefulinc.com/ns/doap#revision> ?ver } " +
"ORDER BY ?label";
Query sparqlQuery = QueryFactory.create(query, Syntax.syntaxARQ);
QueryExecution qexec = QueryExecutionFactory.sparqlService(endpoint, sparqlQuery, graph);
ResultSet results = qexec.execSelect();
ArrayList<FrameworkVersion> arr = new ArrayList<>();
while (results.hasNext()) {
QuerySolution n = results.next();
Resource v = n.getResource("v");
Resource url = n.getResource("url");
Literal label = n.getLiteral("label");
Literal ver = n.getLiteral("ver");
arr.add(new FrameworkVersion(v.getURI(), label.getString(), url.getURI(), ver.getString()));
}
return arr;
}
示例11: fetchAlgorithms
import com.hp.hpl.jena.query.Syntax; //导入依赖的package包/类
private ArrayList<Algorithm> fetchAlgorithms() {
String query = "select * where { ?x a <http://www.linklion.org/ontology#Algorithm> . " +
"?x <http://xmlns.com/foaf/0.1/homepage> ?url . " +
"?x <http://www.w3.org/2000/01/rdf-schema#label> ?label } " +
"ORDER BY ?label";
Query sparqlQuery = QueryFactory.create(query, Syntax.syntaxARQ);
QueryExecution qexec = QueryExecutionFactory.sparqlService(endpoint, sparqlQuery, graph);
ResultSet results = qexec.execSelect();
ArrayList<Algorithm> arr = new ArrayList<>();
while (results.hasNext()) {
QuerySolution n = results.next();
Resource v = n.getResource("x");
Resource url = n.getResource("url");
Literal label = n.getLiteral("label");
arr.add(new Algorithm(v.getURI(), label.getString(), url.getURI()));
}
return arr;
}
示例12: fetchDistinctMappingDataset
import com.hp.hpl.jena.query.Syntax; //导入依赖的package包/类
private HashMap<String, HashMap<String, String>> fetchDistinctMappingDataset() {
String query = "select distinct * where {" +
"?m a <http://www.linklion.org/ontology#Mapping> ." +
"?m <http://www.linklion.org/ontology#hasSource> ?s ." +
"?m <http://www.linklion.org/ontology#hasTarget> ?t ."
+ " } ORDER BY ?m ?s ?t";
Query sparqlQuery = QueryFactory.create(query, Syntax.syntaxARQ);
QueryExecution qexec = QueryExecutionFactory.sparqlService(endpoint, sparqlQuery, graph);
ResultSet results = qexec.execSelect();
HashMap<String, HashMap<String, String>> map = new HashMap<String, HashMap<String, String>>();
while (results.hasNext()) {
HashMap<String, String> st = new HashMap<String, String>();
QuerySolution nextLine = results.next();
Resource mapping = nextLine.getResource("m");
Resource s = nextLine.getResource("s");
Resource t = nextLine.getResource("t");
st.put(s.getURI(), t.getURI());
map.put(mapping.getURI(), st);
}
return map;
}
示例13: linksPerMapping
import com.hp.hpl.jena.query.Syntax; //导入依赖的package包/类
private HashMap<String, Integer> linksPerMapping() {
HashMap<String, Integer> lpm = new HashMap<>();
String query = "select ?x (count(?l) as ?links) where { " +
"?x a <http://www.linklion.org/ontology#Mapping> . " +
"?l <http://www.w3.org/ns/prov#wasDerivedFrom> ?x " +
"} GROUP BY ?x";
Query sparqlQuery = QueryFactory.create(query, Syntax.syntaxARQ);
QueryExecution qexec = QueryExecutionFactory.sparqlService(endpoint, sparqlQuery, graph);
ResultSet results = qexec.execSelect();
while (results.hasNext()) {
QuerySolution n = results.next();
Resource x = n.getResource("x");
Literal links = n.getLiteral("links");
lpm.put(x.getURI(), links.getInt());
}
return lpm;
}
示例14: getUsage
import com.hp.hpl.jena.query.Syntax; //导入依赖的package包/类
private List<Statement> getUsage(Property property, Model model){
List<Statement> stmts = new ArrayList<Statement>();
String sparql = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "
+ "PREFIX owl: <http://www.w3.org/2002/07/owl#> "
+ "SELECT DISTINCT ?concept "
+ "WHERE{"
+ " {<" + property.getURI() + "> rdfs:domain ?concept} "
+ " UNION "
+ " { "
+ " ?concept rdfs:subClassOf|owl:equivalentClass ?restriction . "
+ " ?restriction a owl:Restriction; "
+ " owl:onProperty <" + property.getURI() + "> "
+ " } "
+ "}";
Query query = QueryFactory.create(sparql, Syntax.syntaxARQ);
QueryExecution queryExecution = QueryExecutionFactory.create(query, model);
ResultSet resultSet = queryExecution.execSelect();
while(resultSet.hasNext()){
QuerySolution querySolution = resultSet.next();
Resource concept = querySolution.getResource("concept");
stmts.add(new StatementImpl(property, usage, concept));
}
return stmts;
}
示例15: getDistantEntities
import com.hp.hpl.jena.query.Syntax; //导入依赖的package包/类
private void getDistantEntities(){
File metricFile = new File(
System.getProperty("user.dir") + "/sparql/smells/SemanticallyDistantEntity.sparql");
List<String> lines = null;
try {
lines = Files.readAllLines(metricFile.toPath());
} catch (IOException ex) {
Logger.getLogger(Ontogui.class.getName()).log(Level.SEVERE, null, ex);
}
String queryString = "";
for (String line : lines) {
queryString += line + System.lineSeparator();
}
data.begin(ReadWrite.READ);
List<QuerySolution> rlist = null;
Query query = QueryFactory.create(queryString, Syntax.syntaxARQ);
try (QueryExecution qe = QueryExecutionFactory.create(query, data)) {
ResultSet results = qe.execSelect();
rlist = ResultSetFormatter.toList(results);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Writting to textarea failed!");
e.printStackTrace();
}
instances = new String[rlist.size()];
for(int j = 0; j < rlist.size(); j++){
instances[j] = rlist.get(j).getLiteral("entityname").getString();
}
data.end();
}