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


Java ResourceFactory.createStatement方法代码示例

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


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

示例1: getJenaModel

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
private Model getJenaModel(@NonNull org.eclipse.rdf4j.model.Model model) {
  Model jenaModel = ModelFactory.createDefaultModel();
  java.util.Iterator<org.eclipse.rdf4j.model.Statement> iterator = model.iterator();

  while (iterator.hasNext()) {
    org.eclipse.rdf4j.model.Statement rdf4jStatement = iterator.next();

    // create resource / subject
    Resource resource = rdf4jResourceToJenaResource(jenaModel, rdf4jStatement.getSubject());
    // create property / predicate
    Property property =
        rdf4jPropertyToJenaProperty(jenaModel, (SimpleIRI) rdf4jStatement.getPredicate());
    // create rdfnode / object
    RDFNode node = rdf4jValueToJenaRdfNode(jenaModel, rdf4jStatement.getObject());

    Statement statement = ResourceFactory.createStatement(resource, property, node);
    jenaModel.add(statement);
  }
  return jenaModel;
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:21,代码来源:ShaclValidator.java

示例2: main

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
public static void main(String args[]){
		InstanceSplitModifier sM=new InstanceSplitModifier();
		Resource s = ResourceFactory.createResource("medo.test");
		RDFNode o= ResourceFactory.createTypedLiteral("Medo koko dodo");
		Statement stmt = ResourceFactory.createStatement(s, RDFS.label, o);
		sM.setPartsCount(3);
		List<Property> sP = new ArrayList<Property>();
//		sP.add(ResourceFactory.createProperty("Name1"));
//		sP.add(ResourceFactory.createProperty("Name2"));
//		sP.add(ResourceFactory.createProperty("Name3"));
		sM.setSplitProperties(sP);
		System.out.println(sP);
		System.out.println(sM.split(stmt));
		
		System.out.println(o);
		System.out.println(o.asNode().getLiteral().getLexicalForm());

	}
 
开发者ID:dice-group,项目名称:LASSIE,代码行数:19,代码来源:InstanceSplitModifier.java

示例3: permutat

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
private Statement permutat(Statement stmt) {
        if (!stmt.getObject().isLiteral()) {
//            System.err.println(stmt.getObject() + " is not a literal object");
//            System.err.println("Can NOT permutate a non-literal object!!");
//			System.exit(1);
            return stmt;
        }
        String objectLitral = stmt.getObject().asNode().getLiteral().getLexicalForm();
        String permutatedLitral = permutat(objectLitral);
        RDFNode permutatedObject = ResourceFactory.createTypedLiteral(permutatedLitral);
        Statement result = ResourceFactory.createStatement(stmt.getSubject(), stmt.getPredicate(), permutatedObject);
        return result;
    }
 
开发者ID:dice-group,项目名称:LASSIE,代码行数:14,代码来源:InstancePermutationModifier.java

示例4: abbreviat

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
private Statement abbreviat(Statement stmt) {
        if (!stmt.getObject().isLiteral()) {
//            System.err.println(stmt.getObject() + " is not a literal object");
//            System.err.println("Unable to abbreviat a non-literal object!!");
//			System.exit(1);
            return stmt;
        }
        String objectLitral = stmt.getObject().asNode().getLiteral().getLexicalForm();
        String abbreviatedLitral = abbreviat(objectLitral);
        RDFNode abbreviatedObject = ResourceFactory.createTypedLiteral(abbreviatedLitral);
        Statement result = ResourceFactory.createStatement(stmt.getSubject(), stmt.getPredicate(), abbreviatedObject);
        return result;
    }
 
开发者ID:dice-group,项目名称:LASSIE,代码行数:14,代码来源:InstanceAbbreviationModifier.java

示例5: split

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
private List<Statement> split(Statement stmt){
		List<Statement> result= new ArrayList<Statement>();
		
		if(!stmt.getObject().isLiteral()){
			System.err.println(stmt.getObject() + " is not a literal object");
			System.err.println("Can NOT split a non-literal object!!");
//			System.exit(1);
			result.add(stmt);
			return result;
		}
		

		Resource  subject   = stmt.getSubject();     
		Property  predicate = stmt.getPredicate();   
		RDFNode   object    = stmt.getObject(); 
		String[] splitObject = object.toString().split(" ", partsCount);

		for(int i=0; i<splitObject.length ; i++){
			RDFNode newObject= ResourceFactory.createTypedLiteral(splitObject[i]);
			
			Statement resultStmt;
			// if no user defined new properties then create the new properties as the old property name + "i"
			if(splitProperties.isEmpty()){ 
				Property newPredicate = ResourceFactory.createProperty(predicate.toString()+i);
				resultStmt = ResourceFactory.createStatement(subject, newPredicate, newObject);
			}else{
				resultStmt = ResourceFactory.createStatement(subject, splitProperties.get(i), newObject);
			}
			result.add(resultStmt);
		}

		return result;
	}
 
开发者ID:dice-group,项目名称:LASSIE,代码行数:34,代码来源:InstanceSplitModifier.java

示例6: acronyam

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
private Statement acronyam(Statement stmt){
		if(!stmt.getObject().isLiteral()){
			System.err.println(stmt.getObject() + " is not a literal object");
			System.err.println("Can NOT get acronyam for non-literal object!!");
//			System.exit(1);
			return stmt;
		}
		 String objectLitral     = stmt.getObject().asNode().getLiteral().getLexicalForm();
		 String acronyamedLitral = acronyam(objectLitral);
		 RDFNode acronyamedObject= ResourceFactory.createTypedLiteral(acronyamedLitral);
		 Statement result        = ResourceFactory.createStatement(stmt.getSubject(), stmt.getPredicate(), acronyamedObject);
		return result;
	}
 
开发者ID:dice-group,项目名称:LASSIE,代码行数:14,代码来源:InstanceAcronymModifier.java

示例7: merge

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
private Statement merge(List<Statement> stmts){
	Statement result=null;
	String mergeObjectStr = new String();
	Resource  subject = null;
	Property  predicate = null;
	RDFNode   object = null;

	for(Statement stmt: stmts){
		if(!stmt.getObject().isLiteral()){
			System.err.println(stmt.getObject() + " is not a literal object");
			System.err.println("Can NOT merge a non-literal object!!");
			return stmt;
		}
		subject   = stmt.getSubject();     
		predicate = stmt.getPredicate();   
		object    = stmt.getObject()	; 
		mergeObjectStr = mergeObjectStr.concat(object.asNode().getLiteral().getLexicalForm()+" ");
	}
	mergeObjectStr= mergeObjectStr.substring(0,mergeObjectStr.length()-1); // remove last space
	RDFNode mergeObject= ResourceFactory.createTypedLiteral(mergeObjectStr);
	if(mergeProperty==null){
		result= ResourceFactory.createStatement(subject, predicate, mergeObject);
	}else{
		result= ResourceFactory.createStatement(subject, mergeProperty, mergeObject);
	}
	return result;
}
 
开发者ID:dice-group,项目名称:LASSIE,代码行数:28,代码来源:InstanceMergeModifier.java

示例8: main

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
public static void main(String args[]){
	InstanceMergeModifier mM=new InstanceMergeModifier();
	Resource s = ResourceFactory.createResource("medo.test");
	RDFNode o1= ResourceFactory.createTypedLiteral("koko");
	RDFNode o2= ResourceFactory.createTypedLiteral("Medo");
	Statement stmt1 = ResourceFactory.createStatement(s, RDFS.label, o1);
	Statement stmt2 = ResourceFactory.createStatement(s, RDFS.label, o2);
	List<Statement> stmts= new ArrayList<Statement>();
	stmts.add(stmt1);
	stmts.add(stmt2);
	mM.mergeProperty= ResourceFactory.createProperty("testProperty");
	System.out.println(mM.merge(stmts));

}
 
开发者ID:dice-group,项目名称:LASSIE,代码行数:15,代码来源:InstanceMergeModifier.java

示例9: run

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
private void run() {
    // Make some triples
    dsg.clear();
    Dataset dataset = dsg.toDataset();
    String modelName = "http://example.org/graphs/charles";
    
    String turtle = "@prefix foaf: <http://xmlns.com/foaf/0.1/> ."
            + "@prefix : <http://example.org/> ."
            +":charles a foaf:Person ; "
            + "        foaf:name \"Charles\" ;"
            + "        foaf:knows :jim ."
            + ":jim    a foaf:Person ;"
            + "        foaf:name \"Jim\" ;"
            + "        foaf:knows :charles .";
    
    System.out.println("Make a model and load the turtle into it (client-side)");
    Model model = ModelFactory.createDefaultModel();
    RDFDataMgr.read(model,  new StringReader(turtle), "", Lang.TURTLE);

    System.out.println("Store the model in MarkLogic.");
    dataset.addNamedModel(modelName, model);

    System.out.println("Make a triple by hand.");
    Model moreTriples = ModelFactory.createDefaultModel();
    Statement statement = ResourceFactory.createStatement(
        ResourceFactory.createResource("http://example.org/charles"),
        ResourceFactory.createProperty("http://example.org/hasDog"),
        ResourceFactory.createResource("http://example.org/vashko")
    );
    moreTriples.add( statement );

    System.out.println("Combine models and save");
    model.add(moreTriples);
    dataset.addNamedModel(modelName, model);

    System.out.println("Get it back into a new model (union of two original ones)");
    Model retrievedModel = dataset.getNamedModel(modelName);
    
    System.out.println("Remove model from MarkLogic");
    dataset.removeNamedModel(modelName);
}
 
开发者ID:marklogic,项目名称:marklogic-jena,代码行数:42,代码来源:ModelCRUDExample.java

示例10: misspelling

import org.apache.jena.rdf.model.ResourceFactory; //导入方法依赖的package包/类
/**
 * @param stmt
 * @return
 */
private Statement misspelling(Statement stmt){
    if(!stmt.getObject().isLiteral() || 
            (permutationTriplesCount == 0 && 
            insertionTriplesCount    == 0 && 
            deletionTriplesCount     == 0 && 
            substitutionTriplesCount == 0)){
        return stmt;
    }
    String literalObject    = stmt.getObject().asNode().getLiteral().getLexicalForm();
    String misspelledLiteralObject = new String();

    if(permutationTriplesCount == 0 ){
        permutationFlag = false;
    }
    if(insertionTriplesCount == 0){
        insersionFlag = false;
    }
    if(deletionTriplesCount == 0){
        deletionFlag = false;
    }
    if(substitutionTriplesCount == 0){
        substitutionFlag = false;
    }

    if(permutationFlag){
        misspelledLiteralObject = charPermutation(literalObject);
        permutationTriplesCount--;
        permutationFlag = false;
    }else if(insersionFlag){
        misspelledLiteralObject = charInsertion(literalObject);
        insertionTriplesCount--;
        insersionFlag = false;
    }else if(deletionFlag){
        misspelledLiteralObject = charDeletion(literalObject);
        deletionTriplesCount--;
        deletionFlag = false;
    }else if(substitutionFlag ){
        misspelledLiteralObject = charSubstitution(literalObject);
        substitutionTriplesCount--;
        substitutionFlag = false;
    }

    if(!permutationFlag && !insersionFlag && !deletionFlag && !substitutionFlag){
        permutationFlag  = true;
        insersionFlag    = true;
        deletionFlag     = true;
        substitutionFlag = true;
    }

    RDFNode misspelledObjectNode = ResourceFactory.createTypedLiteral(misspelledLiteralObject);
    Statement result             = ResourceFactory.createStatement(stmt.getSubject(), stmt.getPredicate(), misspelledObjectNode );
    return result;
}
 
开发者ID:dice-group,项目名称:LASSIE,代码行数:58,代码来源:InstanceMisspellingModifier.java


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