本文整理汇总了Java中org.openrdf.model.Resource.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Resource.equals方法的具体用法?Java Resource.equals怎么用?Java Resource.equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openrdf.model.Resource
的用法示例。
在下文中一共展示了Resource.equals方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addPropertyType
import org.openrdf.model.Resource; //导入方法依赖的package包/类
/**
* Add a particular characteristic to a property.
*/
private void addPropertyType(URI p, Resource t) {
OwlProperty prop = getProperty(p);
if (t.equals(OWL.TRANSITIVEPROPERTY)) {
prop.setTransitive();
}
else if (t.equals(OWL.SYMMETRICPROPERTY)) {
prop.setSymmetric();
}
else if (t.equals(OWL2.ASYMMETRICPROPERTY)) {
prop.setAsymmetric();
}
else if (t.equals(OWL.FUNCTIONALPROPERTY)) {
prop.setFunctional();
}
else if (t.equals(OWL.INVERSEFUNCTIONALPROPERTY)) {
prop.setInverseFunctional();
}
else if (t.equals(OWL2.IRREFLEXIVEPROPERTY)) {
prop.setIrreflexive();
}
}
示例2: _getPredicateIds
import org.openrdf.model.Resource; //导入方法依赖的package包/类
private static Set<URI> _getPredicateIds(Set<Statement> statements,
URI subject, URI type) {
if (subject == null)
return Collections.emptySet();
Set<URI> ret = new HashSet<URI>();
for (Statement statement : statements) {
Resource s = statement.getSubject();
if (!s.equals(subject))
continue;
URI p = statement.getPredicate();
if (type != null) {
if (_getTypes(statements, p).contains(type))
ret.add(p);
} else {
ret.add(p);
}
}
return ret;
}
示例3: handleActiveBNode
import org.openrdf.model.Resource; //导入方法依赖的package包/类
/**
* Handles a currently open [] block.
* @param subj the current subject
* @throws IOException
*/
private void handleActiveBNode(Resource subj) throws IOException {
// check if a [] block is currently open
if (storedBNodes.size() > 0) {
// check if [] block has to be closed due to changed subject
if (!subj.equals(storedBNodes.peek())) {
// close last statement and finish [] block
writer.write(" ;");
writer.writeEOL();
writer.decreaseIndentation();
writer.write("]");
// resume last internal status before [] block
statementClosed = false;
storedBNodes.pop();
lastWrittenSubject = storedSubjects.pop();
lastWrittenPredicate = storedPredicates.pop();
}
}
}
示例4: relevantToFuture
import org.openrdf.model.Resource; //导入方法依赖的package包/类
/**
* Use the semantics of a fact to determine whether it could be relevant
* to future reasoners, or whether we should assume we've extracted all
* the information implied by the fact during this iteration. Considers
* semantics but not age.
* @return true if this fact might still be used later.
*/
boolean relevantToFuture(Fact fact) {
// If it's a join rule, it needs to be kept no matter what
if (relevantJoinRule(fact, schema) != Relevance.NONE) {
return true;
}
// Otherwise, it can be skipped under certain circumstances.
Relevance general = relevantFact(fact, schema);
Resource s = fact.getSubject();
Value o = fact.getObject();
// Exception: if subject==object, recursive derivation is limited, so
// we can't make assumptions about what's already been done.
if (!s.equals(o)) {
// Otherwise, if this is a reasoner for the subject, and the fact
// is only relevant to the subject, we can assume this reasoner
// did all the reasoning we needed to.
if (general == Relevance.SUBJECT && node.equals(s)) {
return false;
}
// Same reasoning for the object:
if (general == Relevance.OBJECT && node.equals(o)) {
return false;
}
}
// If we can't skip it, return true if it's ever relevant
return general != Relevance.NONE;
}
示例5: processFact
import org.openrdf.model.Resource; //导入方法依赖的package包/类
/**
* Read in a fact involving this node and make any inferences we can.
* Assumes that incoming triples are received before outgoing triples.
* Recursively call processFact on new triples until nothing else is
* derived.
* @param fact Contains a triple assumed to be relevant to this reasoner
*/
public void processFact(Fact fact) {
Resource subject = fact.getSubject();
URI pred = fact.getPredicate();
Value object = fact.getObject();
// Whether this is a recursive call on a fact that's just been inferred
boolean recursive = fact.getIteration() == currentIteration;
// Figure out what kind of edge this is with respect to this node
boolean incoming = object.equals(node);
boolean outgoing = subject.equals(node);
// Avoid some derivation chains on recursive calls to avoid cycles
boolean skipReflexive = incoming && outgoing && recursive;
// Perform reasoning (incoming before outgoing, so reflexive edges are
// handled in the right order)
if (incoming && !skipReflexive) {
processIncoming(fact);
}
if (outgoing) {
if (pred.equals(RDF.TYPE)) {
types.processType(fact);
}
else {
processOutgoing(fact);
}
}
// If newly-learned facts cause further derivations, apply them recursively
Set<Fact> resultsSoFar = getFacts();
for (Fact newFact : resultsSoFar) {
processFact(newFact);
}
newFacts.addAll(resultsSoFar);
}
示例6: propagateSubClassType
import org.openrdf.model.Resource; //导入方法依赖的package包/类
private void propagateSubClassType(Resource classDef) {
for (Resource c : findClasses(Collections.singleton(classDef))) {
if (c.equals(RDFS.DATATYPE))
continue;
for (Statement stmt : ds.match(null, RDF.TYPE, c)) {
Resource subj = stmt.getSubject();
ds.add(subj, RDF.TYPE, classDef);
}
}
}
示例7: addTo
import org.openrdf.model.Resource; //导入方法依赖的package包/类
private void addTo(Resource node, Value element) {
if (triples.contains(node, RDF.FIRST, null)) {
Resource rest = triples.match(node, RDF.REST, null).objectResource();
if (rest == null || rest.equals(RDF.NIL)) {
rest = vf.createBNode();
triples.remove(node, RDF.REST, null);
triples.add(node, RDF.REST, rest);
}
addTo(rest, element);
} else {
triples.add(node, RDF.FIRST, element);
triples.add(node, RDF.REST, RDF.NIL);
}
}
示例8: handlePendingBNode
import org.openrdf.model.Resource; //导入方法依赖的package包/类
/**
* Special handling of previous BNode object - try to use '[ ... ]'
* Open [] block if current subject is the same BNode,
* else finish last triple.
*
* @param subj the current subject
*/
private void handlePendingBNode(Resource subj) throws IOException {
// check if last triple's object was a BNode object
if (pendingBNode != null) {
// if current triple's subject is the same BNode use [] notation
if (subj.equals(pendingBNode)) {
// first, save the internal status to resume an open [] block
storedBNodes.push(pendingBNode);
storedSubjects.push(lastWrittenSubject);
storedPredicates.push(lastWrittenPredicate);
// then open the new [] block and update the internal status
writer.write("[");
writer.writeEOL();
writer.increaseIndentation();
lastWrittenSubject = pendingBNode;
lastWrittenPredicate = null;
} // otherwise write pending BNode object
else {
writeValue(pendingBNode);
}
pendingBNode = null;
}
}
示例9: relevantFact
import org.openrdf.model.Resource; //导入方法依赖的package包/类
/**
* Determine whether a fact is a triple which might be used by a local
* reasoner for its subject and/or object.
* @param fact Fact to be evaluated
* @param schema Global schema
* @return Relevance to subject and/or object. Relevance means that it's a
* triple that *could* be used in reasoning. It may only be useful
* when combined with other facts, which may or may not exist
* somewhere, so this doesn't guarantee that information will be
* derived.
*/
public static Relevance relevantFact(Fact fact, Schema schema) {
// If this is schema information, we know it's already
// contained in the schema object.
if (Schema.isSchemaTriple(fact.getTriple())) {
return Relevance.NONE;
}
// Otherwise, consider the semantics of the statement:
Resource subject = fact.getSubject();
URI predURI = fact.getPredicate();
Value object = fact.getObject();
boolean relevantToSubject = false;
boolean relevantToObject = false;
// Literals don't get reasoners, so determine whether object is a uri:
boolean literalObject = object instanceof Literal;
// Type statements could be relevant to the subject, if the schema gives
// them any meaning:
if (predURI.equals(RDF.TYPE)) {
// Assume the object is a valid URI
Resource typeURI = (Resource) fact.getObject();
if (typeURI.equals(OWL.NOTHING)
|| schema.hasClass(typeURI)) {
relevantToSubject = true;
}
}
// If the schema knows about the property:
if (schema.hasProperty(predURI)) {
OwlProperty prop = schema.getProperty(predURI);
// Relevant to both:
// Any statement with an asymmetric property
if (prop.isAsymmetric()
// Any statement with a transitive property
|| prop.isTransitive()
// Statements involving restricted properties
|| !prop.getRestrictions().isEmpty()) {
relevantToSubject = true;
relevantToObject = !literalObject;
}
// Relevant to subject:
if (!relevantToSubject && // skip these checks if it already is
// Any statement whose property has a domain.
(!prop.getDomain().isEmpty()
// Choose to apply superproperties here
// (every property is its own superproperty; ignore that)
|| prop.getSuperProperties().size() > 1
// Choose to apply disjoint properties here
|| !prop.getDisjointProperties().isEmpty())) {
relevantToSubject = true;
}
// Relevant to object if the object is not a literal and one other
// condition matches:
if (!literalObject && !relevantToObject &&
// Any statement whose property has a defined range
(!prop.getRange().isEmpty()
// Choose to apply inverse rule in the object's reasoner
|| !prop.getInverseProperties().isEmpty()
// Choose to apply symmetry in the object's reasoner
|| prop.isSymmetric()
// Choose to check irreflexivity in the object's reasoner
|| prop.isIrreflexive() && subject.equals(object))) {
relevantToObject = true;
}
}
return Relevance.get(relevantToSubject, relevantToObject);
}
示例10: processIncoming
import org.openrdf.model.Resource; //导入方法依赖的package包/类
/**
* Process a triple in which this node is the object.
*/
private void processIncoming(Fact fact) {
Resource subject = fact.getSubject();
URI predURI = fact.getPredicate();
OwlProperty prop = schema.getProperty(predURI);
// RL rule prp-rng: Apply range(s), if appropriate
for (Resource type : prop.getRange()) {
types.processType(type, OwlRule.PRP_RNG, fact);
}
// RL rules prp-inv1, prp-inv2: assert any inverse properties
for (URI inverseProp : prop.getInverseProperties()) {
collect(triple(node, inverseProp, subject, OwlRule.PRP_INV, fact));
}
// RL rule prp-symp: Assert the symmetric statement if appropriate
if (prop.isSymmetric()
&& !fact.hasRule(OwlRule.PRP_SYMP)
&& !subject.equals(node)) {
collect(triple(node, predURI, subject, OwlRule.PRP_SYMP, fact));
}
// RL rule prp-irp: (x p x) is inconsistent if p is irreflexive
if (prop.isIrreflexive() && subject.equals(node)) {
collectInconsistency(inconsistency(OwlRule.PRP_IRP, fact));
}
// RL rule prp-trp (part 1/2): We assume triples are sorted with
// incoming first, so store this triple in case it needs to be joined
// with any later outgoing triples with the same property.
if (prop.isTransitive() && !subject.equals(node)
&& checkTransitivityIncoming(fact)) {
if (!transitiveIncoming.containsKey(predURI)) {
transitiveIncoming.put(predURI, new LinkedList<Fact>());
}
transitiveIncoming.get(predURI).add(fact);
}
// RL rule prp-asyp (part 1/2): Store this incoming edge so we can
// compare later outgoing edges against it. (Assume sorted input.)
if (prop.isAsymmetric()) {
if (!asymmetricIncoming.containsKey(predURI)) {
asymmetricIncoming.put(predURI, new LinkedList<Fact>());
}
asymmetricIncoming.get(predURI).add(fact);
}
for (Resource rNode : prop.getRestrictions()) {
OwlClass restriction = schema.getClass(rNode);
// RL rule cls-svf1: Check for a someValuesFrom restriction
Set<Resource> valuesFrom = restriction.someValuesFrom();
// type owl:Thing would be checked by cls-svf2
valuesFrom.remove(OWL.THING);
for (Resource commonType : valuesFrom) {
// If we learn the type, assert the other node's membership in rNode
types.onType(commonType, triple(subject, RDF.TYPE,
rNode, OwlRule.CLS_SVF1, fact));
}
}
}
示例11: allowedByContext
import org.openrdf.model.Resource; //导入方法依赖的package包/类
/**
* Allow only if the context matches the statement. This is a client side filter.
* @param statement
* @param context
* @return
*/
protected static boolean allowedByContext(final Statement statement, final Resource context) {
return context==null || context.equals( statement.getContext() );
}