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

Java TextDatasetFactory类代码示例

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

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



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

示例1: init

import org.apache.jena.query.text.TextDatasetFactory; //导入依赖的package包/类
public void init(String db, String uri, String lucene) {

    	Dataset ds = TDBFactory.createDataset(db);
        
        // Lucene configuration
        try {
            Directory luceneDir = FSDirectory.open(new File(lucene));
            EntityDefinition entDef = new EntityDefinition("comment", "text", RDFS.comment);
            // Set uid in order to remove index entries automatically
            entDef.setUidField("uid");
            StandardAnalyzer stAn = new StandardAnalyzer(Version.LUCENE_4_9);
            dataset = TextDatasetFactory.createLucene(ds, luceneDir, entDef, stAn);
            
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        baseURI = uri;
        servers = new ArrayList<>();
        tdQueue = new PriorityQueue<ThingDescription>();
        loadTDQueue();
    }
 
开发者ID:thingweb,项目名称:thingweb-directory,代码行数:24,代码来源:ThingDirectory.java


示例2: createMemDatasetFromCode

import org.apache.jena.query.text.TextDatasetFactory; //导入依赖的package包/类
/**
 * Creates an in-memory Jena TDB data set and Lucene index from code.
 * @return
 */
public Dataset createMemDatasetFromCode(){
    log.info("Construct an in-memory dataset with in-memory lucene index using code") ;
    TextQuery.init();
    // Build a text dataset by code.
    // Here , in-memory base data and in-memory Lucene index
    // Base data
    Dataset jenads = DatasetFactory.createMem() ;
    Property streetAddress = jenads.getDefaultModel().createProperty("http://schema.org/streetAddress");
    // Define the index mapping
    //EntityDefinition entDef = new EntityDefinition("uri", "text", RDFS.label.asNode()) ;
    EntityDefinition entDef = new EntityDefinition("uri", "text", streetAddress.asNode()) ;
    // Lucene, in memory.
    Directory dir = new RAMDirectory();
    // Join together into a dataset
    Dataset ds = TextDatasetFactory.createLucene(jenads, dir, entDef) ;
    return ds ;
}
 
开发者ID:fusepoolP3,项目名称:p3-osm-transformer,代码行数:22,代码来源:JenaTextConfig.java


示例3: createPersistentDatasetFromCode

import org.apache.jena.query.text.TextDatasetFactory; //导入依赖的package包/类
/**
 * Creates a persistent Jena TDB data set and Lucene index. 
 * @return
 * @throws IOException 
 */
public Dataset createPersistentDatasetFromCode() throws IOException{
    log.info("Construct a persistent Jena data set with lucene index using code") ;
    // Build a text dataset by code.
    TextQuery.init();
    // Remove old files and folders
    deleteFiles(JENA_TDB_TEMP_FOLDER);
    deleteFiles(LUCENE_INDEX_TEMP_FOLDER);
    // Creates new folders
    JENA_TDB_TEMP_FOLDER.mkdirs();
    LUCENE_INDEX_TEMP_FOLDER.mkdirs();
    // Creates persisted Jena data set and Lucene index
    Dataset jenaDataset = TDBFactory.createDataset(JENA_TDB_TEMP_FOLDER.getAbsolutePath()) ;
    // Lucene, persisted.
    Directory luceneIndex = FSDirectory.open(LUCENE_INDEX_TEMP_FOLDER);
    // Define the index mapping
    EntityDefinition entDef = new EntityDefinition("uri", "text", RDFS.label.asNode()) ;
    
    
    // Join together into a dataset
    return TextDatasetFactory.createLucene(jenaDataset, luceneIndex, entDef) ;
}
 
开发者ID:fusepoolP3,项目名称:p3-osm-transformer,代码行数:27,代码来源:JenaTextConfig.java


示例4: SPARQLModelIndex

import org.apache.jena.query.text.TextDatasetFactory; //导入依赖的package包/类
/** Create an index using your own model saving you the time needed to import the model when using an endpoint.
 * If you only have an endpoint or want to index a subset of the triples,
 * use the static methods {@link #createIndex(String, String, List)}, {@link #createClassIndex(String, String)} or {@link #createPropertyIndex(String, String)}.
 * All triples (uri,rdfs:label,label) will be put into the index.
 * @param model the jena model containing the rdf:label statements that you want to index. Changes to the model after the construtor call are probably not indexed.
 * @param minSimilarity Between 0 (maximum fuzzyness) and 1f (no fuzzy matching).
 */
public SPARQLModelIndex(Model model,float minSimilarity)
{
	this.minSimilarity=minSimilarity;
	Dataset ds1 = DatasetFactory.createMem() ;

	EntityDefinition entDef = new EntityDefinition("uri", "text", RDFS.label) ;
	// Lucene, in memory.
	Directory dir =  new RAMDirectory();
	// Join together into a dataset
	dataset = TextDatasetFactory.createLucene(ds1, dir, entDef);
	//		ds.setDefaultModel(model);


	synchronized(model)
	{
		dataset.begin(ReadWrite.WRITE);
		try {
			dataset.getDefaultModel().add(model);
			dataset.commit();
		} finally {
			dataset.end();
		}
	}
	//		this.model = model;
}
 
开发者ID:AKSW,项目名称:rdfindex,代码行数:33,代码来源:SPARQLModelIndex.java


示例5: buildDataSet

import org.apache.jena.query.text.TextDatasetFactory; //导入依赖的package包/类
private Dataset buildDataSet() {
	Dataset ds;
	
	LOGGER.info("Construct a dataset backed by Solr");
	Dataset jenaData = buildBaseDataset();

	if (StringUtils.isNotBlank(jenaConfig.getAssemblerFile())) {
		// The assembler file contains the full mapping detail
		ds = jenaData;
	} else {
		// Define the index mapping
		EntityDefinition entDef = buildEntityDefinition();
		// Define the Solr server
		SolrClient server = new HttpSolrClient(solrConfig.getOntologyUrl());
		// Join together into a dataset
		ds = TextDatasetFactory.create(jenaData, new TextIndexSolr5(server, entDef));
	}
	
	return ds;
}
 
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:21,代码来源:JenaOntologySearch.java


示例6: makeTextDataset

import org.apache.jena.query.text.TextDatasetFactory; //导入依赖的package包/类
private void makeTextDataset() {
    try {
        dir = null;
        if (textIndex == null) {
            log.warn("Opening memory based text index, will not preserved across restarts");
            dir = new RAMDirectory(); 
        } else {
            dir = FSDirectory.open(textIndex);
        }
        EntityDefinition entDef = makeEntityDef();
        dataset = TextDatasetFactory.createLucene(baseDataset, dir, entDef, new StandardAnalyzer(org.apache.jena.query.text.TextIndexLucene.VER)) ;            
    } catch (IOException e) {
        throw new EpiException("Failed to create jena-text lucence index area", e);
    }
}
 
开发者ID:UKGovLD,项目名称:registry-core,代码行数:16,代码来源:TDBStore.java


示例7: main

import org.apache.jena.query.text.TextDatasetFactory; //导入依赖的package包/类
public static void main(String[] args) 
{
	
	TextQuery.init();
	
	Dataset dataset = DatasetFactory.createMem();
	
	EntityDefinition entDef = new EntityDefinition("uri", "text", RDFS.label.asNode()) ;

	// Lucene, in memory.
	Directory dir =  new RAMDirectory();

	// Join together into a dataset
	Dataset ds = TextDatasetFactory.createLucene(dataset, dir, entDef);
	
	
	Model m = ds.getDefaultModel();

	Resource rSubject = m.createResource( "http://ontology.fogbeam.com/example/TestResource1" );
	Resource rSubject2 = m.createResource( "http://ontology.fogbeam.com/example/TestResource2" );
	
	try
	{
	
		Statement s = m.createStatement(rSubject, RDFS.label, "This is a Test Resource" );
	
		m.add( s );
	
		Statement s2 = m.createStatement(rSubject2, RDFS.label, "Bratwurst Test" );
		
		m.add( s2 );
		
		String baseQueryString =
				"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> " +
				"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " +
				"PREFIX dc: <http://purl.org/dc/elements/1.1/> " +
				"PREFIX dcterm: <http://purl.org/dc/terms/> " +
				"PREFIX owl: <http://www.w3.org/2002/07/owl#> " +
				"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
				"PREFIX text: <http://jena.apache.org/text#>";
					
				
		/* Do a SPARQL query using Jena-Text here... */
		String queryString = baseQueryString + " SELECT * { ?s  text:query( 'Test') ; . ?s rdfs:label ?label . }";
			
			
		Query query = QueryFactory.create(queryString) ;
			
			
		QueryExecution qexec = QueryExecutionFactory.create(query, ds );
		QueryExecUtils.executeQuery(qexec);
		
		m.close();
		
		
	}
	catch( Exception e )
	{
		e.printStackTrace();
	}
	
	System.out.println( "done" );
}
 
开发者ID:fogbeam,项目名称:JenaTutorial,代码行数:64,代码来源:JenaTextMain1.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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