org.apache.jena.graph.Triple.predicateMatches()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(4.0k)|赞(0)|评价(0)|浏览(74)

本文整理了Java中org.apache.jena.graph.Triple.predicateMatches()方法的一些代码示例,展示了Triple.predicateMatches()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Triple.predicateMatches()方法的具体详情如下:
包路径:org.apache.jena.graph.Triple
类名称:Triple
方法名:predicateMatches

Triple.predicateMatches介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

class MyHandler implements StreamRDF {
 ...
 public void triple(Triple triple) {
  if (triple.predicateMatches(DBpediaOWL.abstract)) {
   ... process ...
  }
 }
 ...
}
StreamRDF myHandler = new MyHandler();
RDFDataMgr.parse(myHandler, "dbpedia-file.nt");

代码示例来源:origin: SmartDataAnalytics/DL-Learner

/**
 * Returns all triple patterns in given SPARQL query that contain the
 * given predicate. 
 * @param query the SPARQL query.
 * @param predicate the predicate
 * @return
 */
public Set<Triple> extractTriplePatternsWithPredicate(Query query, Node predicate){
  // get all triple patterns
  Set<Triple> triplePatterns = extractTriplePattern(query);
  
  // filter by predicate
  triplePatterns.removeIf(tp -> !tp.predicateMatches(predicate));
  
  return triplePatterns;
}

代码示例来源:origin: SmartDataAnalytics/DL-Learner

@Override
        public int compare(Triple o1, Triple o2) {
          boolean same = o1.subjectMatches(o2.getSubject())
              && o2.predicateMatches(o2.getPredicate())
              && o1.getObject().isVariable() && o2.getObject().isVariable();
//                            && !var2OutgoingTPs.containsKey(o1.getObject());
          if (same) return 0;
          return comp.compare(o1, o2);
        }
      });

代码示例来源:origin: SmartDataAnalytics/DL-Learner

@Override
        public int compare(Triple o1, Triple o2) {
          boolean same = o1.subjectMatches(o2.getSubject())
              && o2.predicateMatches(o2.getPredicate())
              && o1.getObject().isVariable() && o2.getObject().isVariable();
//                            && !var2IncomingTPs.containsKey(o1.getObject());
          if (same) return 0;
          return comp.compare(o1, o2);
        }
      });

代码示例来源:origin: SmartDataAnalytics/DL-Learner

@Override
        public int compare(Triple o1, Triple o2) {
          boolean same = o1.objectMatches(o2.getObject())
              && o2.predicateMatches(o2.getPredicate())
              && o1.getSubject().isVariable() && o2.getSubject().isVariable();
//                            && !var2IncomingTPs.containsKey(o1.getObject());
          if (same) return 0;
          return comp.compare(o1, o2);
        }
      });

代码示例来源:origin: apache/jena

public void testElementMatches()
  {
  assertTrue( NodeCreateUtils.createTriple( "S P O" ).subjectMatches( node( "S" ) ) );
  assertTrue( NodeCreateUtils.createTriple( "S P O" ).predicateMatches( node( "P" ) ) );
  assertTrue( NodeCreateUtils.createTriple( "S P O" ).objectMatches( node( "O" ) ) );
/* */
  assertFalse( NodeCreateUtils.createTriple( "S P O" ).subjectMatches( node( "Z" ) ) );
  assertFalse( NodeCreateUtils.createTriple( "S P O" ).predicateMatches( node( "Q" ) ) );
  assertFalse( NodeCreateUtils.createTriple( "S P O" ).objectMatches( node( "I" ) ) );        
/* */
  assertTrue( NodeCreateUtils.createTriple( "?? P O" ).subjectMatches( node( "SUB" ) ) );
  assertTrue( NodeCreateUtils.createTriple( "S ?? O" ).predicateMatches( node( "PRED" ) ) );
  assertTrue( NodeCreateUtils.createTriple( "S P ??" ).objectMatches( node( "OBJ" ) ) );    
  }

代码示例来源:origin: org.apache.jena/jena-core

public void testElementMatches()
  {
  assertTrue( NodeCreateUtils.createTriple( "S P O" ).subjectMatches( node( "S" ) ) );
  assertTrue( NodeCreateUtils.createTriple( "S P O" ).predicateMatches( node( "P" ) ) );
  assertTrue( NodeCreateUtils.createTriple( "S P O" ).objectMatches( node( "O" ) ) );
/* */
  assertFalse( NodeCreateUtils.createTriple( "S P O" ).subjectMatches( node( "Z" ) ) );
  assertFalse( NodeCreateUtils.createTriple( "S P O" ).predicateMatches( node( "Q" ) ) );
  assertFalse( NodeCreateUtils.createTriple( "S P O" ).objectMatches( node( "I" ) ) );        
/* */
  assertTrue( NodeCreateUtils.createTriple( "?? P O" ).subjectMatches( node( "SUB" ) ) );
  assertTrue( NodeCreateUtils.createTriple( "S ?? O" ).predicateMatches( node( "PRED" ) ) );
  assertTrue( NodeCreateUtils.createTriple( "S P ??" ).objectMatches( node( "OBJ" ) ) );    
  }

相关文章