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


Java Model.size方法代码示例

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


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

示例1: getInstances

import org.openrdf.model.Model; //导入方法依赖的package包/类
public static Model getInstances( URI subtype, URI predtype, URI objtype,
		Collection<URI> propsToInclude, IEngine engine ) {

	// round one: get the relationships themselves
	String query = "CONSTRUCT { ?s ?p ?o } WHERE {\n"
			+ "  ?s a|rdfs:subClassOf+ ?subtype .\n"
			+ "  ?o a|rdfs:subClassOf+ ?objtype .\n"
			+ "  ?p a|rdfs:subPropertyOf+ ?predtype .\n"
			+ "  FILTER( ?s != ?subtype && ?o != ?objtype ) .\n"
			+ "  ?s ?p ?o .\n"
			+ "}";

	ModelQueryAdapter mqa = new ModelQueryAdapter( query );
	mqa.bind( "subtype", subtype );
	mqa.bind( "objtype", objtype );
	mqa.bind( "predtype", predtype );
	mqa.useInferred( true );

	Model model = engine.constructNoEx( mqa );

	// we get inferred rel types as well as declared types, so if we have
	// both, use the declared type
	List<Statement> removers = new ArrayList<>();
	for ( Statement s : model ) {
		URI subj = URI.class.cast( s.getSubject() );
		URI obj = URI.class.cast( s.getObject() );

		Model filts = model.filter( subj, null, obj );
		if ( filts.size() > 1 ) {
			removers.add( new StatementImpl( subj, predtype, obj ) );
		}
	}
	model.removeAll( removers );

	// round two: get properties for the relationships if they exist
	if ( !( null == propsToInclude || propsToInclude.isEmpty() ) ) {
		String propq = "CONSTRUCT { ?p ?prop ?propval } WHERE {\n"
				+ "  ?p rdfs:subPropertyOf+ ?predtype ; ?prop ?propval .\n"
				+ "  VALUES ?prop {" + Utility.implode( propsToInclude ) + "}.\n"
				+ "}";

		ModelQueryAdapter propqa = new ModelQueryAdapter( propq );
		propqa.bind( "predtype", predtype );

		propqa.setModel( model );
		propqa.useInferred( false );

		engine.constructNoEx( propqa );
	}

	return model;
}
 
开发者ID:Ostrich-Emulators,项目名称:semtool,代码行数:53,代码来源:NodeDerivationTools.java


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