當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。