当前位置: 首页>>代码示例>>Java>>正文


Java QueryExecutionFactory.createServiceRequest方法代码示例

本文整理汇总了Java中com.hp.hpl.jena.query.QueryExecutionFactory.createServiceRequest方法的典型用法代码示例。如果您正苦于以下问题:Java QueryExecutionFactory.createServiceRequest方法的具体用法?Java QueryExecutionFactory.createServiceRequest怎么用?Java QueryExecutionFactory.createServiceRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.hp.hpl.jena.query.QueryExecutionFactory的用法示例。


在下文中一共展示了QueryExecutionFactory.createServiceRequest方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initIndividuals

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
/**
 * This method finds all individuals (= instances of owl:Class)
 * 
 * @param dataset
 */
private void initIndividuals(SparqlifyDataset dataset) {
	String indivQueryStr =
			"SELECT distinct ?indiv {" +
				"?indiv a ?cls . ?cls a <" + OWL.Class.getURI() + "> }";
	
	Query indivQuery = QueryFactory.create(indivQueryStr);
	QueryExecution indivQe;
	if (dataset.isSparqlService() && dataset.getSparqlServiceUri()!=null) {
		indivQe = QueryExecutionFactory.createServiceRequest(
				dataset.getSparqlServiceUri(), indivQuery);
	} else {
		indivQe = QueryExecutionFactory.create(indivQuery, dataset);
	}
	
	ResultSet indivRes = indivQe.execSelect();
	while (indivRes.hasNext()) {
		QuerySolution sol = indivRes.next();
		Node indiv = sol.get("indiv").asNode();
		individuals.add(indiv);
	}
}
 
开发者ID:SmartDataAnalytics,项目名称:R2RLint,代码行数:27,代码来源:NoResourceNameClashes.java

示例2: doInBackground

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
@Override
protected ResultSet doInBackground(Void... params) {
    String queryString = "" +
            "PREFIX owl: <http://www.w3.org/2002/07/owl#>\n" +
            "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" +
            "SELECT DISTINCT * WHERE {\n" +
            "?s a owl:Class.\n" +
            "?s rdfs:label ?label\n" +
            "FILTER ( lang(?label) = \"en\" )\n" +
            "} ORDER BY ?label LIMIT 1000\n";
    Query query = QueryFactory.create(queryString);
    QueryExecution qexec = QueryExecutionFactory.createServiceRequest("http://dbpedia.org/sparql", query);
    ResultSet results = qexec.execSelect();
    return results;
}
 
开发者ID:sbrunk,项目名称:jena-android,代码行数:16,代码来源:ResultListActivity.java

示例3: findMarkings

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
private List<Marking> findMarkings(String[] text, File annFile) throws GerbilException {
	List<Marking> markings = new ArrayList<Marking>();
	try (BufferedReader breader = new BufferedReader(new InputStreamReader(
			new FileInputStream(annFile), Charset.forName("UTF-8")))) {
		String line;
		
		while ((line = breader.readLine()) != null) {
			if(line.isEmpty()){
				continue;
			}
			String[] annotation = line.split("\t");
			int searchID = getTrecID(text[0]);
			int annoID = getTrecID(annotation[0]);
			if(searchID == annoID){
				int start = text[1].indexOf(annotation[3]);
				int length = annotation[3].length();
				
				//FIXME time consuming!
                   String freebaseID = annotation[2].substring(1, annotation[2].length()).replace("/",".");
                   Query query = QueryFactory.create(queryTemp.replace("%%v%%", freebaseID));
                   QueryExecution qexec = QueryExecutionFactory.createServiceRequest(DBPEDIA_SERVICE, query);
                   String uri =  qexec.execSelect().next().getResource("s").getURI();
                   
				
				markings.add(new NamedEntity(start, length, uri));
			}
			else if(annoID > searchID){
				//There is no annotation for the given text
				break;
			}
		}
	} catch (IOException e) {
		throw new GerbilException("Exception while reading dataset.", e,
				ErrorTypes.DATASET_LOADING_ERROR);
	}

	return markings;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:39,代码来源:ERDDataset2.java

示例4: ckeckLeadingZeros

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
private void ckeckLeadingZeros(SparqlifyDataset dataset)
		throws NotImplementedException, SQLException {
	// http://www.w3.org/TR/2003/WD-rdf-syntax-grammar-20030123/#rdf-ns-uri
	
	String queryStr =
		"Prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
		"SELECT * { " +
			"?s ?p ?o . " +
			"FILTER(regex(str(?p), \"^http://www.w3.org/1999/02/22-rdf-syntax-ns#_0\")) " +
		"}";
	
	Query query = QueryFactory.create(queryStr);
	
	QueryExecution qe;
	if (dataset.isSparqlService() && dataset.getSparqlServiceUri()!=null) {
		qe = QueryExecutionFactory.createServiceRequest(
				dataset.getSparqlServiceUri(), query);
	} else {
		qe = QueryExecutionFactory.create(query, dataset);
	}
	ResultSet res = qe.execSelect();
	
	List<Triple> leadingZeroTriples = new ArrayList<Triple>();
	while(res.hasNext())
	{
		QuerySolution solution = res.nextSolution();
		Resource subj = solution.getResource("s");
		Resource pred = solution.getResource("p");
		RDFNode obj = solution.get("o");
		Triple leadingzeroTriple = new Triple(subj.asNode(), pred.asNode(), obj.asNode());
		leadingZeroTriples.add(leadingzeroTriple);
	}
	qe.close(); 
	
	for (Triple triple : leadingZeroTriples) {
		Set<ViewQuad<ViewDefinition>> viewQuads = pinpointer.getViewCandidates(triple);
		writeTripleMeasureToSink(leadingZeroVal, triple, viewQuads);
	}
}
 
开发者ID:SmartDataAnalytics,项目名称:R2RLint,代码行数:40,代码来源:CorrectContainerUse.java

示例5: getQueryExecution

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
private QueryExecution getQueryExecution(String queryStr, SparqlifyDataset dataset) {
    Query query = QueryFactory.create(queryStr);
    QueryExecution qe;
    if (dataset.isSparqlService() && dataset.getSparqlServiceUri() != null) {
        qe = QueryExecutionFactory.createServiceRequest(
                dataset.getSparqlServiceUri(), query);
    } else {
        qe = QueryExecutionFactory.create(query, dataset);
    }
    
    return qe;
}
 
开发者ID:SmartDataAnalytics,项目名称:R2RLint,代码行数:13,代码来源:CorrectCollectionUse.java

示例6: checkResourceInterpretability

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
private void checkResourceInterpretability(Node node,
		TriplePosition pos, Triple triple, SparqlifyDataset dataset)
		throws NotImplementedException, SQLException {
	
	boolean ontPropStatementFound = false;
	
	// check if resource is further described using one of the proposed
	// properties
	for (Property ontProp : ontDefProperties) {
		String queryStr = "ASK { <" + node.getURI() + "> <" + ontProp.getURI() + "> ?o }";
		
		Query query = QueryFactory.create(queryStr);
		
		QueryExecution qe;
		if (dataset.isSparqlService() && dataset.getSparqlServiceUri()!=null) {
			qe = QueryExecutionFactory.createServiceRequest(
					dataset.getSparqlServiceUri(), query);
		} else {
			qe = QueryExecutionFactory.create(query, dataset);
		}
		
		ontPropStatementFound = qe.execAsk();
		qe.close();
		if (ontPropStatementFound) break;
	}
	
	if (!ontPropStatementFound) {
		Set<ViewQuad<ViewDefinition>> viewQuads = pinpointer
				.getViewCandidates(triple.asTriple());
		
		writeNodeTripleMeasureToSink(0, pos, triple.asTriple(), viewQuads);
	}
}
 
开发者ID:SmartDataAnalytics,项目名称:R2RLint,代码行数:34,代码来源:OWLOntologyDeclarations.java

示例7: getClasses

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
/**
 * @param dataset
 * @return
 */
private Set<Node> getClasses(Model dataset) {
	
	if (dataset instanceof SparqlifyDataset) {
		dataset = (SparqlifyDataset) dataset;
	}
	
	Set<Node> classes = new HashSet<Node>();
	
	// ont model approach
	OntModel ontDataset = 
			ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_TRANS_INF, dataset);
	ExtendedIterator<OntClass> ontClassesIt = ontDataset.listClasses();
	
	while (ontClassesIt.hasNext()) {
		OntClass cls = ontClassesIt.next();
		classes.add(cls.asNode());
	}
	
	// explicit query approach
	String queryStr =
			"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> "
			+ "PREFIX owl: <http://www.w3.org/2002/07/owl#> "
			+ "SELECT distinct ?cls  {"
				+ "{?cls a rdfs:Class} "
				+ "UNION {?cls a owl:Class} "
				+ "UNION {[] a ?cls} }";
	Query query = QueryFactory.create(queryStr);
	
	QueryExecution qe;
	if (dataset instanceof SparqlifyDataset
			&& ((SparqlifyDataset) dataset).isSparqlService()
			&& ((SparqlifyDataset) dataset).getSparqlServiceUri() != null) {
		String serviceUri = ((SparqlifyDataset) dataset).getSparqlServiceUri();
		qe = QueryExecutionFactory.createServiceRequest(serviceUri, query);
	} else {
		qe = QueryExecutionFactory.create(query, dataset);
	}
	
	ResultSet res = qe.execSelect();
	
	while(res.hasNext()) {
		QuerySolution solution = res.nextSolution();
		RDFNode solNode = solution.get("cls");
		classes.add(solNode.asNode());
	}
	qe.close();
	
	return classes;
}
 
开发者ID:SmartDataAnalytics,项目名称:R2RLint,代码行数:54,代码来源:VocabularyClassCompleteness.java

示例8: execute

import com.hp.hpl.jena.query.QueryExecutionFactory; //导入方法依赖的package包/类
private ResultSet execute(String endPoint, String queryString) throws Exception {
	 Query query = QueryFactory.create(queryString) ;
	 QueryEngineHTTP qexec = QueryExecutionFactory.createServiceRequest(endPoint, query); 
	 ResultSet results = qexec.execSelect() ;
	 return results;
}
 
开发者ID:dwws-ufes,项目名称:2014-trires,代码行数:7,代码来源:PesquisaTrabalhosBibliotecasService.java


注:本文中的com.hp.hpl.jena.query.QueryExecutionFactory.createServiceRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。