本文整理匯總了Java中com.hp.hpl.jena.graph.Triple.getPredicate方法的典型用法代碼示例。如果您正苦於以下問題:Java Triple.getPredicate方法的具體用法?Java Triple.getPredicate怎麽用?Java Triple.getPredicate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hp.hpl.jena.graph.Triple
的用法示例。
在下文中一共展示了Triple.getPredicate方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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));
}
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: getVarsOfTriple
import com.hp.hpl.jena.graph.Triple; //導入方法依賴的package包/類
private ArrayList<String> getVarsOfTriple(Triple t) {
ArrayList<String> vars = new ArrayList<String>();
Node subject = t.getSubject();
Node predicate = t.getPredicate();
Node object = t.getObject();
if(subject.isVariable())
vars.add(subject.getName());
if(predicate.isVariable())
vars.add(predicate.getName());
if(object.isVariable())
vars.add(object.getName());
return vars;
}
示例7: getVarsOfTriple
import com.hp.hpl.jena.graph.Triple; //導入方法依賴的package包/類
protected ArrayList<String> getVarsOfTriple(Triple t) {
ArrayList<String> vars = new ArrayList<String>();
Node subject = t.getSubject();
Node predicate = t.getPredicate();
Node object = t.getObject();
if (subject.isVariable())
vars.add(subject.getName());
if (predicate.isVariable())
vars.add(predicate.getName());
if (object.isVariable())
vars.add(object.getName());
return vars;
}
示例8: getVarsOfTriple
import com.hp.hpl.jena.graph.Triple; //導入方法依賴的package包/類
private ArrayList<String> getVarsOfTriple(Triple t) {
ArrayList<String> vars = new ArrayList<String>();
Node subject = t.getSubject();
Node predicate = t.getPredicate();
Node object = t.getObject();
if(subject.isVariable())
vars.add(subject.getName());
if(predicate.isVariable())
vars.add(predicate.getName());
if(object.isVariable())
vars.add(object.getName());
return vars;
}
示例9: getMappingVarsOfTriple
import com.hp.hpl.jena.graph.Triple; //導入方法依賴的package包/類
/**
* From a triple the method extracts the variable names
* and the columns to be selected from the table referring to that variable.
*
* @param t
* @return
*/
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;
}
示例10: selectWithVariables
import com.hp.hpl.jena.graph.Triple; //導入方法依賴的package包/類
/**
* Creates a {@link NodeRelation} by applying a triple pattern
* to the TripleRelation. If the triple contains variables, then
* the variables will be bound to the corresponding values
* in the resulting NodeRelation. {@link Node#ANY} will be
* converted to a variable "subject", "predicate", "object"
* depending on its position in the triple pattern.
*
* For example, selecting (?x :name ?name) would produce a
* NodeRelation with ?x bound to the subjects and ?name bound to the
* objects of this TripleRelation.
*
* TODO This is never called at the moment. Why!?
*
* @param t A triple pattern involving variables
* @return A NodeRelation over the variables occurring in the triple pattern
*/
public TripleRelation selectWithVariables(Triple t) {
// Select non-variable parts of the triple
TripleRelation selected = selectTriple(t);
// Replace Node.ANY with "subject", "predicate", "object"
Node s = t.getSubject() == Node.ANY ? SUBJECT : t.getSubject();
Node p = t.getPredicate() == Node.ANY ? PREDICATE : t.getPredicate();
Node o = t.getObject() == Node.ANY ? OBJECT : t.getObject();
// Collect variable names and their bound node makers
VariableConstraints nodeMakers = new VariableConstraints();
nodeMakers.addIfVariable(s, nodeMaker(SUBJECT), baseRelation().aliases());
nodeMakers.addIfVariable(p, nodeMaker(PREDICATE), baseRelation().aliases());
nodeMakers.addIfVariable(o, nodeMaker(OBJECT), baseRelation().aliases());
// Did the same variable occur more than once in the pattern, rendering it unsatisfiable?
if (!nodeMakers.satisfiable()) {
return TripleRelation.EMPTY;
}
MutableRelation mutator = new MutableRelation(selected.baseRelation());
Expression constraint = nodeMakers.constraint();
if (!constraint.isTrue()) {
// Same variable occured more than once, so we add a constraint to the base relation
mutator.select(constraint);
}
mutator.project(nodeMakers.allProjections());
return fromNodeRelation(new NodeRelation(
mutator.immutableSnapshot(), nodeMakers.toMap()));
}
示例11: translate
import com.hp.hpl.jena.graph.Triple; //導入方法依賴的package包/類
@Override
public SQLStatement translate(String resultName) {
this.resultName = resultName;
List<Triple> triples = opBGP.getPattern().getList();
HashMap<Node, TripleGroup> tripleGroups = new HashMap<Node, TripleGroup>();
// empty PrefixMapping when prefixes should be expanded
if (expandPrefixes) {
prefixes = PrefixMapping.Factory.create();
}
// Partition triples by common subject into triple groups.
// Each triple group can then result into its own subquery.
// Finally all subqueries are joined by shared variable.
for (Triple triple : triples) {
Node key = null;
boolean fromTripletable = false;
if (triple.getPredicate().isVariable()) {
key = triple.getPredicate();
fromTripletable = true;
} else {
key = triple.getSubject();
fromTripletable = false;
}
if (!tripleGroups.containsKey(key)) {
tripleGroups.put(key, new TripleGroup(this.resultName + "_"
+ tableNumber++, prefixes, fromTripletable));
}
tripleGroups.get(key).add(triple);
}
TripleGroup group = null;
ArrayList<TripleGroup> groups = new ArrayList<TripleGroup>();
groups.addAll(tripleGroups.values());
group = groups.get(0);
groups.remove(0);
// joins are necessary
if (groups.size() > 0) {
ArrayList<String> onConditions = new ArrayList<String>();
ArrayList<SQLStatement> rights = new ArrayList<SQLStatement>();
// Greedy approach: Find join partner with most shared vars.
Map<String, String[]> group_shifted = Schema.shiftToParent(group.getMappings(), group.getName());
while (groups.size() > 0) {
int index = findBestJoin(group_shifted, groups);
TripleGroup right = groups.get(index);
Map<String, String[]> right_shifted = Schema.shiftToParent(right.getMappings(), right.getName());
onConditions.add(JoinUtil.generateConjunction(JoinUtil
.getOnConditions(group_shifted, right_shifted)));
group_shifted.putAll(right_shifted);
rights.add(right.translate());
groups.remove(index);
}
this.resultSchema = group_shifted;
Join join = new Join(getResultName(), group.translate(), rights, onConditions, JoinType.INNER);
join.setDistinct(true);
return join;
}
// no join needed
this.resultName = group.getName();
SQLStatement res = group.translate();
this.resultSchema = group.getMappings();
return res;
}
示例12: translate
import com.hp.hpl.jena.graph.Triple; //導入方法依賴的package包/類
@Override
public SQLStatement translate(String resultName) {
this.resultName = resultName;
List<Triple> triples = opBGP.getPattern().getList();
HashMap<Node, SparkComplexTripleGroup> tripleGroups = new HashMap<Node, SparkComplexTripleGroup>();
// empty PrefixMapping when prefixes should be expanded
if (expandPrefixes) {
prefixes = PrefixMapping.Factory.create();
}
// Partition triples by common subject into triple groups.
// Each triple group can then result into its own subquery.
// Finally all subqueries are joined by shared variable.
for (Triple triple : triples) {
Node key = null;
boolean fromTripletable = false;
if (triple.getPredicate().isVariable()) {
key = triple.getPredicate();
fromTripletable = true;
} else {
key = triple.getSubject();
fromTripletable = false;
}
if (!tripleGroups.containsKey(key)) {
tripleGroups.put(key,
new SparkComplexTripleGroup(this.resultName + "_" + tableNumber++, prefixes, fromTripletable));
}
tripleGroups.get(key).add(triple);
}
SparkComplexTripleGroup group = null;
ArrayList<SparkComplexTripleGroup> groups = new ArrayList<SparkComplexTripleGroup>();
groups.addAll(tripleGroups.values());
group = groups.get(0);
groups.remove(0);
// joins are necessary - if more than 1 subject
if (groups.size() > 0) {
ArrayList<String> onConditions = new ArrayList<String>();
ArrayList<SQLStatement> rights = new ArrayList<SQLStatement>();
// Greedy approach: Find join partner with most shared vars.
Map<String, String[]> group_shifted = Schema.shiftToParent(group.getMappings(), group.getName());
while (groups.size() > 0) {
int index = findBestJoin(group_shifted, groups);
SparkComplexTripleGroup right = groups.get(index);
Map<String, String[]> right_shifted = Schema.shiftToParent(right.getMappings(), right.getName());
onConditions.add(JoinUtil.generateConjunction(JoinUtil.getOnConditions(group_shifted, right_shifted)));
group_shifted.putAll(right_shifted);
rights.add(right.translate());
groups.remove(index);
}
this.resultSchema = group_shifted;
Join join = new Join(getResultName(), group.translate(), rights, onConditions, JoinType.INNER);
join.setDistinct(true);
return join;
}
// no join needed
this.resultName = group.getName();
SQLStatement res = group.translate();
this.resultSchema = group.getMappings();
return res;
}
示例13: translate
import com.hp.hpl.jena.graph.Triple; //導入方法依賴的package包/類
@Override
public SQLStatement translate(String resultName) {
this.resultName = resultName;
List<Triple> triples = opBGP.getPattern().getList();
HashMap<Node, ImpalaComplexTripleGroup> tripleGroups = new HashMap<Node, ImpalaComplexTripleGroup>();
// empty PrefixMapping when prefixes should be expanded
if (expandPrefixes) {
prefixes = PrefixMapping.Factory.create();
}
// Partition triples by common subject into triple groups.
// Each triple group can then result into its own subquery.
// Finally all subqueries are joined by shared variable.
for (Triple triple : triples) {
Node key = null;
boolean fromTripletable = false;
if (triple.getPredicate().isVariable()) {
key = triple.getPredicate();
fromTripletable = true;
} else {
key = triple.getSubject();
fromTripletable = false;
}
if (!tripleGroups.containsKey(key)) {
tripleGroups.put(key, new ImpalaComplexTripleGroup(this.resultName + "_"
+ tableNumber++, prefixes, fromTripletable));
}
tripleGroups.get(key).add(triple);
}
ImpalaComplexTripleGroup group = null;
ArrayList<ImpalaComplexTripleGroup> groups = new ArrayList<ImpalaComplexTripleGroup>();
groups.addAll(tripleGroups.values());
group = groups.get(0);
groups.remove(0);
// joins are necessary
if (groups.size() > 0) {
ArrayList<String> onConditions = new ArrayList<String>();
ArrayList<SQLStatement> rights = new ArrayList<SQLStatement>();
// Greedy approach: Find join partner with most shared vars.
Map<String, String[]> group_shifted = Schema.shiftToParent(group.getMappings(), group.getName());
while (groups.size() > 0) {
int index = findBestJoin(group_shifted, groups);
ImpalaComplexTripleGroup right = groups.get(index);
Map<String, String[]> right_shifted = Schema.shiftToParent(right.getMappings(), right.getName());
onConditions.add(JoinUtil.generateConjunction(JoinUtil
.getOnConditions(group_shifted, right_shifted)));
group_shifted.putAll(right_shifted);
rights.add(right.translate());
groups.remove(index);
}
this.resultSchema = group_shifted;
Join join = new Join(getResultName(), group.translate(), rights, onConditions, JoinType.INNER);
join.setDistinct(true);
return join;
}
// no join needed
this.resultName = group.getName();
SQLStatement res = group.translate();
this.resultSchema = group.getMappings();
return res;
}
示例14: convertToBoundingBox
import com.hp.hpl.jena.graph.Triple; //導入方法依賴的package包/類
public void convertToBoundingBox(InputStream in, OutputStream out, String baseUri,boolean mvbb){
setRdfWriter(new WriterStreamRDFBlocks(out));
getRdfWriter().base(baseUri);
getRdfWriter().prefix("inst", baseUri);
getRdfWriter().prefix("rdf", Namespace.RDF);
getRdfWriter().prefix("xsd", Namespace.XSD);
getRdfWriter().prefix("owl", Namespace.OWL);
getRdfWriter().prefix("geom", GEOM.getURI());
getRdfWriter().start();
getRdfWriter().finish();
PipedRDFIterator<Triple> iter = new PipedRDFIterator<Triple>();
final PipedRDFStream<Triple> stream = new PipedTriplesStream(iter);
ExecutorService executor = Executors.newSingleThreadExecutor();
Runnable parser = new Runnable() {
public void run() {
RDFDataMgr.parse(stream, in, RDFLanguages.TTL);
}
};
executor.submit(parser);
while (iter.hasNext()) {
Triple t = iter.next();
Node subject = t.getSubject();
Node predicate = t.getPredicate();
Node object = t.getObject();
if(predicate.equals(GEOM.asBody.asNode())){
Geometry g=EwktReader.parseGeometry((String)object.getLiteralValue());
if(!g.isEmpty()){
AABBVisitor av=new AABBVisitor();
g.accept(av);
AABB aabb=av.getAABB();
getRdfWriter().triple(new Triple(subject,GEOM.asAABB.asNode(),NodeFactory.createLiteral(EwktWriter.writeGeometry(aabb.toPolyhedralSurface()))));
if(mvbb){
MVBBVisitor mv=new MVBBVisitor();
g.accept(mv);
Box mvbbb=mv.getMVBB();
getRdfWriter().triple(new Triple(subject,GEOM.asMVBB.asNode(),NodeFactory.createLiteral(EwktWriter.writeGeometry(mvbbb.toPolyhedralSurface()))));
}
}
}
}
executor.shutdown();
System.out.println("Model parsed!");
System.out.println("Finished!");
}