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


Java DatasetGraph.contains方法代码示例

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


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

示例1: matchSingleTmx

import com.hp.hpl.jena.sparql.core.DatasetGraph; //导入方法依赖的package包/类
static public String matchSingleTmx(Node tmx, DatasetGraph g, Model m){
    String sq="";
    if (g.contains(null, tmx, typeNode, instantNode)) { // One Instant
        sq += "?ev <http://semanticweb.cs.vu.nl/2009/11/sem/hasTime> ?t . ?t a <http://www.w3.org/TR/owl-time#Instant> . ";
        for (Iterator<Quad> iter = g.find(null, tmx, specificTimeNode, null); iter.hasNext(); ) {
            Quad q = iter.next();
            sq += "?t <http://www.w3.org/TR/owl-time#inDateTime> <" + q.asTriple().getObject() + "> . ";
        }
    } else { // One Interval

        String intervalQuery = "SELECT ?begin ?end WHERE { <" + tmx + ">  <http://www.w3.org/TR/owl-time#hasBeginning> ?begin ; <http://www.w3.org/TR/owl-time#hasEnd> ?end . }";

        Query inQuery = QueryFactory.create(intervalQuery);

        // Create a single execution of this query, apply to a model
        // which is wrapped up as a Dataset
        QueryExecution inQexec = QueryExecutionFactory.create(inQuery, m);

        try {
            // Assumption: it’s a SELECT query.
            ResultSet inrs = inQexec.execSelect();
            // The order of results is undefined.
            for (; inrs.hasNext(); ) {
                QuerySolution evrb = inrs.nextSolution();
                // Get title - variable names do not include the ’?’
                String begin = evrb.get("begin").toString();
                String end = evrb.get("end").toString();

                String unionQuery = "{ ?ev <http://semanticweb.cs.vu.nl/2009/11/sem/hasTime> ?t . ?t a <http://www.w3.org/TR/owl-time#Interval> . ?t <http://www.w3.org/TR/owl-time#hasBeginning> <" + begin + "> ; <http://www.w3.org/TR/owl-time#hasEnd> <" + end + "> . } ";
                unionQuery += "UNION ";
                unionQuery += "{ ?ev <http://semanticweb.cs.vu.nl/2009/11/sem/hasEarliestBeginTimeStamp> ?t1 . ?t1 a <http://www.w3.org/TR/owl-time#Instant> . ?t1 <http://www.w3.org/TR/owl-time#inDateTime> <" + begin + "> . ?ev <http://semanticweb.cs.vu.nl/2009/11/sem/hasEarliestEndTimeStamp> ?t2 . ?t2 a <http://www.w3.org/TR/owl-time#Instant> . ?t2 <http://www.w3.org/TR/owl-time#inDateTime> <" + end + "> . } ";
                sq += unionQuery;
            }
        } finally {
            inQexec.close();
        }
    }
    return sq;
}
 
开发者ID:newsreader,项目名称:StreamEventCoreference,代码行数:40,代码来源:ProcessEventObjectsStream.java


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