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


Java Triple類代碼示例

本文整理匯總了Java中com.hp.hpl.jena.graph.Triple的典型用法代碼示例。如果您正苦於以下問題:Java Triple類的具體用法?Java Triple怎麽用?Java Triple使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Triple類屬於com.hp.hpl.jena.graph包,在下文中一共展示了Triple類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: buildBGP

import com.hp.hpl.jena.graph.Triple; //導入依賴的package包/類
private void buildBGP(OpBGP op) {
final List<Triple> triples = op.getPattern().getList();
for (final Triple triple : triples) {
    final Node subjectNode = triple.getSubject();
    final Node predicateNode = triple.getPredicate();
    final Node objectNode = triple.getObject();

    final String subject = PrefixUtil.collapsePrefix(FmtUtils
	    .stringForNode(subjectNode, prefixes));
    final String object = PrefixUtil.collapsePrefix(FmtUtils
	    .stringForNode(objectNode, prefixes));
    final String predicate = PrefixUtil.collapsePrefix(FmtUtils
	    .stringForNode(predicateNode, prefixes));

    if (bgp == null) {
	bgp = new ArrayList<TriplePattern>();
    }
    bgp.add(new TriplePattern(subject, predicate, object));
}
   }
 
開發者ID:aschaetzle,項目名稱:S2X,代碼行數:21,代碼來源:SparkBGP.java

示例2: reorder

import com.hp.hpl.jena.graph.Triple; //導入依賴的package包/類
public BasicPattern reorder(BasicPattern pattern) {
    inputPattern = pattern;
    List<Triple> triples = inputPattern.getList();

    int idx = chooseFirst();
    Triple triple = triples.get(idx);
    outputPattern.add(triple);
    joinSchema.addAll(getVarsOfTriple(triple));
    triples.remove(idx);

    while (!triples.isEmpty()) {
        idx = chooseNext();
        triple = triples.get(idx);
        outputPattern.add(triple);
        joinSchema.addAll(getVarsOfTriple(triple));
        triples.remove(idx);
    }

    return outputPattern;
}
 
開發者ID:aschaetzle,項目名稱:S2RDF,代碼行數:21,代碼來源:ReorderNoCross.java

示例3: getMappingVarsOfTriple

import com.hp.hpl.jena.graph.Triple; //導入依賴的package包/類
private HashMap<String, String[]> getMappingVarsOfTriple(Triple t) {
	HashMap<String, String[]> result = new HashMap<String, String[]>();
	Node subject = t.getSubject();
	Node predicate = t.getPredicate();
	Node object = t.getObject();
	if (subject.isVariable())
		result.put(subject.getName(),
				new String[] { Tags.SUBJECT_COLUMN_NAME });
	if (predicate.isVariable()) {
		result.put(predicate.getName(),
				new String[] { Tags.PREDICATE_COLUMN_NAME });
	}
	if (object.isVariable()) {
		result.put(object.getName(),
				new String[] { Tags.OBJECT_COLUMN_NAME });
	}
	return result;
}
 
開發者ID:aschaetzle,項目名稱:S2RDF,代碼行數:19,代碼來源:TripleGroup.java

示例4: reorder

import com.hp.hpl.jena.graph.Triple; //導入依賴的package包/類
public BasicPattern reorder(BasicPattern pattern) {
	inputPattern = pattern;
	List<Triple> triples = inputPattern.getList();

	int idx = chooseFirst();
	Triple triple = triples.get(idx);
	outputPattern.add(triple);
	addToJoinVars(getVarsOfTriple(triple));
	triples.remove(idx);

	while (!triples.isEmpty()) {
		idx = chooseNext();
		triple = triples.get(idx);
		outputPattern.add(triple);
		addToJoinVars(getVarsOfTriple(triple));		
		triples.remove(idx);
	}

	return outputPattern;
}
 
開發者ID:aschaetzle,項目名稱:PigSPARQL,代碼行數:21,代碼來源:ReorderNoCross.java

示例5: getSchemaOfTriple

import com.hp.hpl.jena.graph.Triple; //導入依賴的package包/類
protected ArrayList<String> getSchemaOfTriple(Triple t) {
	ArrayList<String> schema = new ArrayList<String>();
	Node subject = t.getSubject();
	Node predicate = t.getPredicate();
	Node object = t.getObject();
	if (subject.isVariable())
		schema.add(subject.getName());
	else
		schema.add(Tags.NO_VAR);
	if (predicate.isVariable())
		schema.add(predicate.getName());
	else
		schema.add(Tags.NO_VAR);
	if (object.isVariable())
		schema.add(object.getName());
	else
		schema.add(Tags.NO_VAR);
	return schema;
}
 
開發者ID:aschaetzle,項目名稱:PigSPARQL,代碼行數:20,代碼來源:PigBGP.java

示例6: reorder

import com.hp.hpl.jena.graph.Triple; //導入依賴的package包/類
public BasicPattern reorder(BasicPattern pattern) {
	inputPattern = pattern;
	List<Triple> triples = inputPattern.getList();

	int idx = chooseFirst();
	Triple triple = triples.get(idx);
	outputPattern.add(triple);
	joinSchema.addAll(getVarsOfTriple(triple));
	triples.remove(idx);

	while (!triples.isEmpty()) {
		idx = chooseNext();
		triple = triples.get(idx);
		outputPattern.add(triple);
		joinSchema.addAll(getVarsOfTriple(triple));
		triples.remove(idx);
	}

	return outputPattern;
}
 
開發者ID:aschaetzle,項目名稱:Sempala,代碼行數:21,代碼來源:ReorderNoCross.java

示例7: getMappingVarsOfTriple

import com.hp.hpl.jena.graph.Triple; //導入依賴的package包/類
private HashMap<String, String[]> getMappingVarsOfTriple(Triple t) {
	HashMap<String, String[]> result = new HashMap<String, String[]>();
	Node subject = t.getSubject();
	Node predicate = t.getPredicate();
	Node object = t.getObject();
	if (subject.isVariable()) {
		result.put(subject.getName(), new String[] { Tags.SUBJECT_COLUMN_NAME });
	}
	if (predicate.isVariable()) {
		selectFromTripleStore = true;
		result.put(predicate.getName(), new String[] { Tags.PREDICATE_COLUMN_NAME });
	}
	if (object.isVariable()) {
		if (selectFromTripleStore) {
			result.put(object.getName(), new String[] { Tags.OBJECT_COLUMN_NAME });
		} else {
			String objectString = object.getName();
			String predicateString = getPropertyFromURI(FmtUtils
					.stringForNode(predicate, prefixMapping), false);
			result.put(objectString, new String[] { SpecialCharFilter.filter(predicateString) });
		}
	}
	return result;
}
 
開發者ID:aschaetzle,項目名稱:Sempala,代碼行數:25,代碼來源:SparkComplexTripleGroup.java

示例8: getMappingVarsOfTriple

import com.hp.hpl.jena.graph.Triple; //導入依賴的package包/類
private HashMap<String, String[]> getMappingVarsOfTriple(Triple t) {
	HashMap<String, String[]> result = new HashMap<String, String[]>();
	Node subject = t.getSubject();
	Node predicate = t.getPredicate();
	Node object = t.getObject();
	if (subject.isVariable())
		result.put(subject.getName(),
				new String[] { Tags.SUBJECT_COLUMN_NAME });
	if (predicate.isVariable()) {
		selectFromTripleStore = true;
		result.put(predicate.getName(),
				new String[] { Tags.PREDICATE_COLUMN_NAME });
	}
	if (object.isVariable()) {
		if (selectFromTripleStore) {
			result.put(object.getName(),
					new String[] { Tags.OBJECT_COLUMN_NAME });
		} else {
			result.put(object.getName(), new String[] { SpecialCharFilter
					.filter(FmtUtils
							.stringForNode(predicate, prefixMapping)) });
		}
	}
	return result;
}
 
開發者ID:aschaetzle,項目名稱:Sempala,代碼行數:26,代碼來源:TripleGroup.java

示例9: creatRDF

import com.hp.hpl.jena.graph.Triple; //導入依賴的package包/類
private static void creatRDF(String[] line) {
    String s = line[0];
    String p = line[1];
    String o = line[2];

    Node nodeS = Node.createURI(s);
    Node nodeP = Node.createURI("<" + p + ">");
    Node nodeO = null;

    if (o.contains("http")) {
        nodeO = Node.createURI("<" + o + ">");
    } else if (o.contains(".")) {
        //double
        NodeFactoryExtra c = new NodeFactoryExtra();
        nodeO = c.doubleToNode(Double.parseDouble(o));
    } else {
        nodeO = Node.createLiteral(o);
    }
    Triple triple = Triple.create(nodeS, nodeS, nodeS);

    //Statement sta = ResourceFactory.createStatement(s, p, o);
    graph.add(triple);

}
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:25,代碼來源:DataRdfizer.java

示例10: nextStreamingTripleKeyValue

import com.hp.hpl.jena.graph.Triple; //導入依賴的package包/類
protected boolean nextStreamingTripleKeyValue() throws IOException, InterruptedException {
    if(rdfIter == null) return false;
    setKey();
    write("<sem:triples xmlns:sem='http://marklogic.com/semantics'>");
    int max = MAXTRIPLESPERDOCUMENT;
    while (max > 0 && rdfIter.hasNext()) {
        Triple triple = (Triple) rdfIter.next();
        write("<sem:triple>");
        write(subject(triple.getSubject()));
        write(predicate(triple.getPredicate()));
        write(object(triple.getObject()));
        write("</sem:triple>");
        notifyUser();
        max--;
    }
    write("</sem:triples>\n");

    if (!rdfIter.hasNext()) {
        pos = 1;
    }

    writeValue();
    return true;
}
 
開發者ID:marklogic,項目名稱:marklogic-contentpump,代碼行數:25,代碼來源:RDFReader.java

示例11: prepareBindings

import com.hp.hpl.jena.graph.Triple; //導入依賴的package包/類
public BindingQueryPlan prepareBindings(GraphQuery q, Node[] variables) {   
	this.variables = variables;
	this.indexes = new HashMap<Node,Integer>();
	for (int i = 0; i < variables.length; i++) {
		indexes.put(variables[i], new Integer(i));
	}
	BasicPattern pattern = new BasicPattern();
	for (Triple t: q.getPattern()) {
		pattern.add(t);
	}
	Plan plan = QueryEngineD2RQ.getFactory().create(new OpBGP(pattern), dataset, null, null);
	final ExtendedIterator<Domain> queryIterator = new Map1Iterator<Binding,Domain>(new BindingToDomain(), plan.iterator());
	return new BindingQueryPlan() {
		public ExtendedIterator<Domain> executeBindings() {
			return queryIterator;
		}
	};
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:19,代碼來源:D2RQQueryHandler.java

示例12: selectTriple

import com.hp.hpl.jena.graph.Triple; //導入依賴的package包/類
public TripleRelation selectTriple(Triple t) {
	MutableRelation newBase = new MutableRelation(baseRelation());
	NodeMaker s = nodeMaker(SUBJECT).selectNode(t.getSubject(), newBase);
	if (s.equals(NodeMaker.EMPTY)) return null;
	NodeMaker p = nodeMaker(PREDICATE).selectNode(t.getPredicate(), newBase);
	if (p.equals(NodeMaker.EMPTY)) return null;
	NodeMaker o = nodeMaker(OBJECT).selectNode(t.getObject(), newBase);
	if (o.equals(NodeMaker.EMPTY)) return null;
	Set<ProjectionSpec> projections = new HashSet<ProjectionSpec>();
	projections.addAll(s.projectionSpecs());
	projections.addAll(p.projectionSpecs());
	projections.addAll(o.projectionSpecs());
	newBase.project(projections);
	if (!s.projectionSpecs().isEmpty() && o.projectionSpecs().isEmpty()) {
	    newBase.swapLimits();
	}
	return new TripleRelation(newBase.immutableSnapshot(), s, p, o);
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:19,代碼來源:TripleRelation.java

示例13: prepareBindings

import com.hp.hpl.jena.graph.Triple; //導入依賴的package包/類
public BindingQueryPlan prepareBindings(Query q, Node[] variables) {   
	this.variables = variables;
	this.indexes = new HashMap<Node,Integer>();
	for (int i = 0; i < variables.length; i++) {
		indexes.put(variables[i], new Integer(i));
	}
	BasicPattern pattern = new BasicPattern();
	for (Triple t: q.getPattern()) {
		pattern.add(t);
	}
	Plan plan = QueryEngineD2RQ.getFactory().create(new OpBGP(pattern), dataset, null, null);
	final ExtendedIterator<Domain> queryIterator = new Map1Iterator<Binding,Domain>(new BindingToDomain(), plan.iterator());
	return new BindingQueryPlan() {
		public ExtendedIterator<Domain> executeBindings() {
			return queryIterator;
		}
	};
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:19,代碼來源:D2RQQueryHandler.java

示例14: testLang

import com.hp.hpl.jena.graph.Triple; //導入依賴的package包/類
public void testLang()
{
	List<Triple> pattern = new ArrayList<Triple>();
	pattern.add(Triple.create(Node.createVariable("s"), RDFS.label.asNode(), Node.createVariable("o")));
	NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
	
	NodeRelation label_fr_be  = search("table1", "label_fr_be", rels);
	NodeRelation label_en     = search("table1", "label_en", rels);
	NodeRelation label_noLang = search("table1", "label", rels);
	
	Expr filterFR    = new E_Equals(new E_Lang(new ExprVar("o")), NodeValue.makeString("fr"));
	Expr filterEN_TAG_EN = new E_Equals(new E_Lang(new ExprVar("o")), NodeValue.makeNode("en", "en", (String) null));
	Expr filterFR_BE = new E_Equals(new E_Lang(new ExprVar("o")), NodeValue.makeString("fr-BE"));
	Expr filter      = new E_Equals(new E_Lang(new ExprVar("o")), NodeValue.makeString(""));
	
	assertEquals("LANG(label_fr_be) = \"fr\" should be FALSE",   Expression.FALSE, TransformExprToSQLApplyer.convert(filterFR, label_fr_be));
	assertEquals("LANG(label_en) = \"fr\" should be FALSE",      Expression.FALSE, TransformExprToSQLApplyer.convert(filterFR, label_en));
	assertEquals("LANG(label_fr_be) = \"fr_be\" should be TRUE", Expression.TRUE,  TransformExprToSQLApplyer.convert(filterFR_BE, label_fr_be));
	assertEquals("LANG(label_en) = \"en\"@en should be FALSE",   Expression.FALSE, TransformExprToSQLApplyer.convert(filterEN_TAG_EN, label_en));
	assertEquals("LANG(label_noLang) = \"\" should be TRUE",     Expression.TRUE,  TransformExprToSQLApplyer.convert(filter, label_noLang));
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:22,代碼來源:ExprTransformTest2.java

示例15: testDataType

import com.hp.hpl.jena.graph.Triple; //導入依賴的package包/類
public void testDataType()
{
	List<Triple> pattern = new ArrayList<Triple>();
	pattern.add(Triple.create(Node.createVariable("s"), Node.createURI("http://example.org/value"), Node.createVariable("o")));
	NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
	
	NodeRelation intvalue = search("table2", "intvalue", rels);
	NodeRelation value = search("table2", "value", rels);
	
	pattern.clear();
	pattern.add(Triple.create(Node.createVariable("s"), RDFS.label.asNode(), Node.createVariable("o")));
	rels = translate(pattern, "optimizer/filtertests.n3");
	
	NodeRelation langliteral = search("table1", "label_en", rels);
	
	Expr filterint    = new E_Equals(new E_Datatype(new ExprVar("o")), NodeValueNode.makeNode(Node.createURI(XSDDatatype.XSDint.getURI())));
	Expr filterstring = new E_Equals(new E_Datatype(new ExprVar("o")), NodeValueNode.makeNode(Node.createURI(XSDDatatype.XSDstring.getURI())));
	
	assertEquals("DATATYPE(intliteral) = xsd:int should be TRUE",       Expression.TRUE, TransformExprToSQLApplyer.convert(filterint, intvalue));
	assertEquals("DATATYPE(simpleliteral) = xsd:string should be TRUE", Expression.TRUE, TransformExprToSQLApplyer.convert(filterstring, value));
	assertEquals("DATATYPE(langliteral) = xsd:string should be TRUE",   Expression.TRUE, TransformExprToSQLApplyer.convert(filterstring, langliteral));
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:23,代碼來源:ExprTransformTest2.java


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