當前位置: 首頁>>代碼示例>>Java>>正文


Java ResourceFactory.createStatement方法代碼示例

本文整理匯總了Java中com.hp.hpl.jena.rdf.model.ResourceFactory.createStatement方法的典型用法代碼示例。如果您正苦於以下問題:Java ResourceFactory.createStatement方法的具體用法?Java ResourceFactory.createStatement怎麽用?Java ResourceFactory.createStatement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hp.hpl.jena.rdf.model.ResourceFactory的用法示例。


在下文中一共展示了ResourceFactory.createStatement方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addRowToMODEL

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
private void addRowToMODEL(List<Statement> sa, String key, String puri) {
	for (Statement s : sa) {
		if (MODEL.contains(s)) {
			continue;
		}
		// add to existing resource with same key if exists
		if (s.getPredicate().getLocalName().equals(key)) {
			ResIterator it	=	MODEL.listResourcesWithProperty(s.getPredicate(), s.getObject());
			if (it.hasNext()) { // assume all members are equal
				Resource rsc	= it.nextResource(); // get parent
				Property p	= ResourceFactory.createProperty(genOURI(), puri);
				Statement st	= ResourceFactory.createStatement(rsc, p, s.getSubject());

				MODEL.add(st);

				continue;
			}
		}

		MODEL.add(s);
	}
}
 
開發者ID:wxwilcke,項目名稱:mdb2rdf,代碼行數:23,代碼來源:RdbToRdf.java

示例2: convertRowToStatement

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
private List<Statement> convertRowToStatement(Table table, Row row, Resource rcs) {
	List<Statement> sa	= new ArrayList<Statement>(row.size()); 
	int i = 0;
	
	Set<String> attrs = row.keySet();
	for (String attr : attrs) {
		RDFNode attrRcs;
		Object value	= row.get(attr);
		if (value == null || excludedValue(attr.toString(), value.toString())) { // dealing with empty and excluded values
			continue;
		} else {
			attrRcs	= createRDFNode(table.getColumn(attr), value);
		}

		Property p	= ResourceFactory.createProperty(genOURI(), attr.toString());
		Statement s	= ResourceFactory.createStatement(rcs, p, attrRcs);
		
		sa.add(s);
	}

	return sa;
}
 
開發者ID:wxwilcke,項目名稱:mdb2rdf,代碼行數:23,代碼來源:RdbToRdf.java

示例3: execute

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
@Override
public void execute(TridentTuple tuple, TridentCollector collector) {
	Statement newStatement = ResourceFactory.createStatement(ResourceFactory.createResource(tuple.getString(0)), 
			ResourceFactory.createProperty(tuple.getString(1)),
			ResourceFactory.createResource(tuple.getString(2)));
	// The name of the graph is stored and added to the tuple at the emission
	// If the new triple matches the starting pattern and the graph is not empty, the graph is emitted.
	if (statementPattern.test(newStatement)) {
		if (!graph.isEmpty()) {
			// The values emitted correspond to the name of the graph (earthquake URI), the timestamp of creation, and the graph.
			collector.emit(new Values(graphName, System.currentTimeMillis(), graph));
			graph.clear();
		}
		graphName = tuple.getString(0);
	}
	graph.add(newStatement.asTriple());
}
 
開發者ID:allaves,項目名稱:storm-query-operators,代碼行數:18,代碼來源:Triple2Graph.java

示例4: execute

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
@Override
	public void execute(Tuple tuple) {
		Statement newStatement = ResourceFactory.createStatement(ResourceFactory.createResource(tuple.getString(0)), 
				ResourceFactory.createProperty(tuple.getString(1)),
				ResourceFactory.createResource(tuple.getString(2)));
		// The name of the graph is stored and added to the tuple at the emission
		// If the new triple matches the starting pattern and the graph is not empty, the graph is emitted.
		if (startingPattern.test(newStatement)) {
			if (!graph.isEmpty()) {
				// The values emitted correspond to the name of the graph (earthquake URI), the timestamp of creation, and the graph.
//				RDFDataMgr.write(System.out, graph, Lang.N3);
				collector.emit(new Values(graphName, System.currentTimeMillis(), graph));
				System.out.println("EMITTED GRAPH: " + graphName);
				graph.clear();
			}
			graphName = tuple.getString(0);
		}
		graph.add(newStatement.asTriple());
		collector.ack(tuple);
	}
 
開發者ID:allaves,項目名稱:storm-query-operators,代碼行數:21,代碼來源:Triple2GraphBolt.java

示例5: getDataStatement

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
public static Statement getDataStatement(String subject, String predicate, String object)
{
    return ResourceFactory.createStatement(
        ResourceFactory.createResource(subject),
            ResourceFactory.createProperty(predicate),
            ResourceFactory.createPlainLiteral(object)
    );
}
 
開發者ID:daedafusion,項目名稱:knowledge,代碼行數:9,代碼來源:ModelUtil.java

示例6: getObjectStatement

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
public static Statement getObjectStatement(String subject, String predicate, String object)
{
    return ResourceFactory.createStatement(
            ResourceFactory.createResource(subject),
            ResourceFactory.createProperty(predicate),
            ResourceFactory.createResource(object)
    );
}
 
開發者ID:daedafusion,項目名稱:knowledge,代碼行數:9,代碼來源:ModelUtil.java

示例7: getTypeStatement

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
public static Statement getTypeStatement(String subject, String object)
{
    return ResourceFactory.createStatement(
            ResourceFactory.createResource(subject),
            ResourceFactory.createProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),
            ResourceFactory.createResource(object)
    );
}
 
開發者ID:daedafusion,項目名稱:knowledge,代碼行數:9,代碼來源:ModelUtil.java

示例8: map1

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
@Override
public Statement map1( final BigdataStatement blzgStmt )
{
    final Resource s = convertToJenaResource( blzgStmt.getSubject() );
    final Property p = convertToJenaProperty( blzgStmt.getPredicate() );
    final RDFNode  o = convertToJenaRDFNode( blzgStmt.getObject() );

    return ResourceFactory.createStatement( s, p, o );
}
 
開發者ID:hartig,項目名稱:BlazegraphBasedTPFServer,代碼行數:10,代碼來源:BigdataStatementToJenaStatementMapper.java

示例9: writeConceptsToRdf

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
/**
	 * This method adds concepts to a model retrieved from original RDF file 
	 * and stores it in enriched RDF file.
	 * @param concepts The list of concepts
	 * @param inputFileName The original RDF file
	 * @param pathToAnalysisFolder The location for enriched RDF file
	 */
	public boolean writeConceptsToRdf(List<Concept> concepts, String inputFileName, String pathToAnalysisFolder) {

		boolean res = false;
		
    	Model model = createModelFromRdfFile(inputFileName);
		
		ResIterator itrConcepts = model.listSubjects();
		while (itrConcepts.hasNext()) {
			Resource rdfNode = itrConcepts.next();
        	System.out.println("rdfNode: " + rdfNode.toString());
        	Property p = null;
        	String object = null;
			StmtIterator itr = model.listStatements(rdfNode, p, object);
	    	
	    	while (itr.hasNext()) {
	    		Statement statement = itr.next();
	        	Triple triple = statement.asTriple();
	        	Concept curConcept = getConceptByUrl(concepts, triple.getSubject().toString());
		        if (curConcept.getCloseMatch() != null 
		        		&& StringUtils.isNotEmpty(curConcept.getCloseMatch().get(WIKIDATA_ID_CLOSE_MATCH_KEY))) {
    				// set subject, predicate, object
	        		Resource subject = statement.getSubject();
	        		Property predicate = ResourceFactory.createProperty(CLOSE_MATCH_PREDICATE_URL);
	        		Resource rdfObject = ResourceFactory.createResource(
	        				WIKIDATA_BASE_URL +
	        				curConcept.getCloseMatch().get(WIKIDATA_ID_CLOSE_MATCH_KEY));
	        		Statement newStatement = ResourceFactory.createStatement(subject, predicate, rdfObject);
       				model.add(newStatement);
       				break;
	        	}	
	    	}
		}
		
    	// write model to standard out
//    	model.write(System.out);
		res = writeModelToFile(model, pathToAnalysisFolder + RDF_RES_FILE_NAME);
		
		return res;
	}
 
開發者ID:gsergiu,項目名稱:music-genres,代碼行數:47,代碼來源:SkosUtils.java

示例10: prepareStatement

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入方法依賴的package包/類
/**
 * This is specific to addTriple
 * @param sub
 * @param pred
 * @param obj
 * @return
 * @throws InvalidNameException
 * @throws MalformedURLException 
 */
protected Statement prepareStatement(String sub, String pred, String obj) throws InvalidNameException, MalformedURLException {
	RDFNode[] spo = prepareSubjectPredicateObject(sub, pred, obj);
	if (spo != null && spo.length == 3) {
		Resource r = (Resource) spo[0];
		Property p = (Property) spo[1];
		RDFNode n = spo[2];
		Statement s = null;
		if (r == null) {
			throw new InvalidNameException("Not able to resolve triple subject '" + sub + "'.");
		}
		else if (p == null) {
			throw new InvalidNameException("Not able to resolve triple predicate '" + pred + "'.");			
		}
		else if (n == null) {
			if (schemaModel != null) {
				schemaModel.write(System.out, "N-TRIPLE");
			}
			if (dataModel != null) {
				dataModel.write(System.out, "N-TRIPLE");
			}
			throw new InvalidNameException("Not able to resolve triple object '" + obj + "'.");
		}
		else {
			s = ResourceFactory.createStatement(r, p, n);
		}
		return s;
	}
	throw new InvalidNameException("Unexpected error resolving triple <" + sub + ", " + pred + ", " + obj + ">");
}
 
開發者ID:crapo,項目名稱:sadlos2,代碼行數:39,代碼來源:JenaReasonerPlugin.java


注:本文中的com.hp.hpl.jena.rdf.model.ResourceFactory.createStatement方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。