• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Filter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.hp.hpl.jena.util.iterator.Filter的典型用法代码示例。如果您正苦于以下问题:Java Filter类的具体用法?Java Filter怎么用?Java Filter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Filter类属于com.hp.hpl.jena.util.iterator包,在下文中一共展示了Filter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: readOwlFile

import com.hp.hpl.jena.util.iterator.Filter; //导入依赖的package包/类
static void readOwlFile (String pathToOwlFile) {
        OntModel ontologyModel =
                ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
        ontologyModel.read(pathToOwlFile, "RDF/XML-ABBREV");
       // OntClass myClass = ontologyModel.getOntClass("namespace+className");

        OntClass myClass = ontologyModel.getOntClass(ResourcesUri.nwr+"domain-ontology#Motion");
        System.out.println("myClass.toString() = " + myClass.toString());
        System.out.println("myClass.getSuperClass().toString() = " + myClass.getSuperClass().toString());

        //List list =
              //  namedHierarchyRoots(ontologyModel);


       Iterator i = ontologyModel.listHierarchyRootClasses()
                .filterDrop( new Filter() {
                    public boolean accept( Object o ) {
                        return ((Resource) o).isAnon();
                    }} ); ///get all top nodes and excludes anonymous classes

       // Iterator i = ontologyModel.listHierarchyRootClasses();
        while (i.hasNext()) {
            System.out.println(i.next().toString());
/*            OntClass ontClass = ontologyModel.getOntClass(i.next().toString());
            if (ontClass.hasSubClass()) {

            }*/
        }

        String q = createSparql("event", "<http://www.newsreader-project.eu/domain-ontology#Motion>");
        System.out.println("q = " + q);
        QueryExecution qe = QueryExecutionFactory.create(q,
                ontologyModel);
        for (ResultSet rs = qe.execSelect() ; rs.hasNext() ; ) {
            QuerySolution binding = rs.nextSolution();
            System.out.println("binding = " + binding.toString());
            System.out.println("Event: " + binding.get("event"));
        }

        ontologyModel.close();
    }
 
开发者ID:newsreader,项目名称:StreamEventCoreference,代码行数:42,代码来源:OwlReader.java


示例2: findShortestPath

import com.hp.hpl.jena.util.iterator.Filter; //导入依赖的package包/类
/**
 * <p>Answer the shortest path from the <code>start</code> resource to the <code>end</code> RDF node,
 * such that every step on the path is accepted by the given filter. A path is a {@link List}
 * of RDF {@link Statement}s. The subject of the first statement in the list is <code>start</code>,
 * and the object of the last statement in the list is <code>end</code>.</p>
 * <p>The <code>onPath</code> argument is a {@link Filter}, which accepts a statement and returns
 * true if the statement should be considered to be on the path. To search for an unconstrained
 * path, pass {@link Filter#any} as an argument. To search for a path whose predicates match a
 * fixed restricted set of property names, pass an instance of {@link PredicatesFilter}.</p>
 * <p>If there is more than one path of minimal length from <code>start</code> to <code>end</code>,
 * this method returns an arbitrary one. The algorithm is blind breadth-first search,
 * with loop detection.</p>
 *
 * @param m The model in which we are seeking a path
 * @param start The starting resource
 * @param end The end, or goal, node
 * @param onPath A filter which determines whether a given statement can be considered part
 * of the path
 * @return A path, consisting of a list of statements whose first subject is <code>start</code>,
 * and whose last object is <code>end</code>, or null if no such path exists.
 */
public static Path findShortestPath( Model m, Resource start, RDFNode end, Filter<Statement> onPath ) {
    List<Path> bfs = new LinkedList<Path>();
    Set<Resource> seen = new HashSet<Resource>();

    // initialise the paths
    for (Iterator<Statement> i = m.listStatements( start, null, (RDFNode) null ).filterKeep( onPath ); i.hasNext(); ) {
        bfs.add( new Path().append( i.next() ) );
    }

    // search
    Path solution = null;
    while (solution == null && !bfs.isEmpty()) {
        Path candidate = bfs.remove( 0 );

        if (candidate.hasTerminus( end )) {
            solution = candidate;
        }
        else {
            Resource terminus = candidate.getTerminalResource();
            if (terminus != null) {
                seen.add( terminus );

                // breadth-first expansion
                for (Iterator<Statement> i = terminus.listProperties().filterKeep( onPath ); i.hasNext(); ) {
                    Statement link = i.next();

                    // no looping allowed, so we skip this link if it takes us to a node we've seen
                    if (!seen.contains( link.getObject() )) {
                        bfs.add( candidate.append( link ) );
                    }
                }
            }
        }
    }

    return solution;
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:59,代码来源:OntTools.java


示例3: find

import com.hp.hpl.jena.util.iterator.Filter; //导入依赖的package包/类
@Override
public ExtendedIterator<Triple> find( Node s, Node p, Node o ) {
    return SimpleEventManager.notifyingRemove( this, 
            base.find( s, p, o ).filterDrop( new Filter<Triple>() {
                @Override
                public boolean accept(Triple t) {
                    if (t.getSubject().isLiteral()) return true;
                    if (t.getPredicate().isBlank() || t.getPredicate().isLiteral()) return true;
                    return false;
                }
            } ) );
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:13,代码来源:SafeGraph.java


示例4: filterOn

import com.hp.hpl.jena.util.iterator.Filter; //导入依赖的package包/类
@Override public Filter<Triple> filterOn( final Node n )
{ 
return n.isConcrete() 
    ? new Filter<Triple>() 
        { @Override public boolean accept( Triple x ) { return n.equals( x.subj ); } }
    : anyTriple
    ;
}
 
开发者ID:jacekkopecky,项目名称:parkjam,代码行数:9,代码来源:Triple.java


示例5: getDefaultNsFilter

import com.hp.hpl.jena.util.iterator.Filter; //导入依赖的package包/类
/** Returns a filter to keep only properties in the default ORO namespace,
 * thus removing properties inferred from RDF or OWL models.
 */
public static Filter<OntProperty> getDefaultNsFilter() {
	 return new Filter<OntProperty>(){
            @Override
			public boolean accept(OntProperty p) {
                if (p.getNameSpace().equals(DEFAULT_NS))                
                	return true;
                return false;
            }
		};
}
 
开发者ID:severin-lemaignan,项目名称:oro-server,代码行数:14,代码来源:Namespaces.java


示例6: filterKeep

import com.hp.hpl.jena.util.iterator.Filter; //导入依赖的package包/类
@Override
public ExtendedIterator<Triple> filterKeep(Filter<Triple> f) {
	// TODO Auto-generated method stub
	return null;
}
 
开发者ID:semr,项目名称:neo4jena,代码行数:6,代码来源:ExecutionResultIterator.java


示例7: filterDrop

import com.hp.hpl.jena.util.iterator.Filter; //导入依赖的package包/类
@Override
public ExtendedIterator<Triple> filterDrop(Filter<Triple> f) {
	// TODO Auto-generated method stub
	return null;
}
 
开发者ID:semr,项目名称:neo4jena,代码行数:6,代码来源:ExecutionResultIterator.java


示例8: processCategories

import com.hp.hpl.jena.util.iterator.Filter; //导入依赖的package包/类
/**
 * Process categories.
 * @param ontModelUtil ontology model utility
 * @param queryCriteria query criteria
 * @param search search ontology class
 * @param terms terms
 */
private void processCategories(
  OntModelUtil ontModelUtil,
  QueryCriteria queryCriteria,
  OntClass search,
  Terms terms) {
  OntClassMap classMap = new OntClassMap();
  Iterator<String> CatIt = ontCtx.getCategories().keySet().iterator();
  while (CatIt.hasNext()) {
    String cat = CatIt.next();
    String code = ontModelUtil.getCode(cat, locale);
    if (code != null) {
      classMap.put(cat, ontCtx.getModel().getOntClass(code));
    }
  }

  int numberrecord = 0;
  Iterator<String> CatOnt = classMap.keySet().iterator();
  while (CatOnt.hasNext()) {
    String key = CatOnt.next();
    OntTools.Path path =
      OntTools.findShortestPath(ontCtx.getModel(), search, classMap.get(key),
      Filter.any);
    if (path != null) {

      float ii = 1;
      int TopicRecord = numberrecord;
      Term countCat = new Term(key, Relationship.SubClassOf, path.size());
      terms.add(countCat);
      numberrecord++;

      for (Iterator it = path.iterator(); it.hasNext();) {

        Statement statement = (Statement) it.next();
        OntClass onts =
          ontCtx.getModel().getOntClass(statement.getSubject().getNameSpace());
        OntClass onto =
          ontCtx.getModel().getOntClass(statement.getObject().toString());
        if (statement.getPredicate().getLocalName().equalsIgnoreCase(
          "seeAlso")) {
          ii = ii - (1 - queryCriteria.getSeeAlsoWeight());
        } else if (statement.getPredicate().getLocalName().equalsIgnoreCase(
          "subClassOf")) {
          ii = ii - (1 - queryCriteria.getSubClassWeight());
        }
        Term countCatDetails = new Term(onts.getLabel(locale.getLanguage()),
          Relationship.parse(statement.getPredicate().getLocalName()),
          onto.getLabel(locale.getLanguage()), ii);
        terms.add(countCatDetails);
        numberrecord++;
        ii++;

      }
      Term countCat1 = new Term(key, Relationship.SubClassOf, ii - 1);
      terms.set(TopicRecord, countCat1);
    }
  }
}
 
开发者ID:mhogeweg,项目名称:OntologyService,代码行数:65,代码来源:OntologyProcessor.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AggregatorFactory类代码示例发布时间:2022-05-22
下一篇:
Java CharacterUtils类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap