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

Java TDBFactory类代码示例

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

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



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

示例1: main

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
public static void main(String[] args) {

    if (args.length != 3) {
      System.err.println("Wrong arguments");
      showUsage();
    }
    System.out.println("Model file   : " + args[0]);
    System.out.println("Model URI    : " + args[1]);
    System.out.println("Model tdb dir: " + args[2]);

    Dataset dataset = TDBFactory.createDataset(args[2]);
    try {
      Model model = dataset.getNamedModel(args[1]);
      TDBLoader.loadModel(model, args[0]);
    } finally {
      dataset.close();
    }
  }
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:19,代码来源:SKOSTDBLoader.java


示例2: loadOEModelToTdb

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
/**
  * Fetch a model from Ontology Editor, load and return as TDB-backed Jena model.
  *
  * @param endpoint
  * @param tDbDirectoryPath
  * @return
* @throws OEConnectionException 
* @throws IOException 
  */
 public static Model loadOEModelToTdb(OEModelEndpoint endpoint, String tDbDirectoryPath) throws IOException, OEConnectionException {
   Preconditions.checkNotNull(endpoint);
   Preconditions.checkArgument(!Strings.isNullOrEmpty(tDbDirectoryPath));

   if (logger.isDebugEnabled()) {
     logger.debug("OEModelEndpoint: {}", endpoint);
     logger.debug("TDB Dir path   : {}", tDbDirectoryPath);
   }

   String modelAsTTL = endpoint.fetchData();

   Dataset dataset = TDBFactory.createDataset(tDbDirectoryPath);
   Model model = dataset.getNamedModel(endpoint.modelIri);
   model.read(new ByteArrayInputStream(modelAsTTL.getBytes()), "TTL");
   return model;
 }
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:26,代码来源:ModelLoader.java


示例3: init

import org.apache.jena.tdb.TDBFactory; //导入依赖的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


示例4: queryData

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
public static List<String> queryData(String query){
	Dataset db = TDBFactory.createDataset("temp/dataset");
	db.begin(ReadWrite.READ);
    Model model = db.getDefaultModel();
    Query q = QueryFactory.create(query);
    QueryExecution qexec = QueryExecutionFactory.create(query, model);
    ResultSet results = qexec.execSelect();
    List<String> answer = new ArrayList<String>();
    while(results.hasNext()){
    	QuerySolution t = results.nextSolution();
    	RDFNode x  = t.get("x");
    	String s = x.toString();
	System.out.println(s);
    	answer.add(s.substring(7));
    }
    qexec.close();
    db.close();
    return answer;
}
 
开发者ID:kunal15595,项目名称:smart-question-answering-nlp,代码行数:20,代码来源:Database.java


示例5: mainTDB

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
public static void mainTDB(String...argv) throws IOException {
    DatasetGraphTDB dsg = ((DatasetGraphTransaction)TDBFactory.createDatasetGraph()).get() ;
    String DIR = "testing/Inf" ;
    String DATA_FILE = DIR+"/rdfs-data.ttl" ;
    String VOCAB_FILE = DIR+"/rdfs-vocab.ttl" ;
    String RULES_FILE = DIR+"/rdfs-min.rules" ;

    Model vocab = RDFDataMgr.loadModel(VOCAB_FILE) ;
    Model data = RDFDataMgr.loadModel(DATA_FILE) ;
    String rules = FileUtils.readWholeFileAsUTF8(RULES_FILE) ;
    rules = rules.replaceAll("#[^\\n]*", "") ;

    // TDB
    
    InferenceSetupRDFS_TDB setup = new InferenceSetupRDFS_TDB(vocab, dsg, false) ;
    //Graph graph = new GraphRDFS(setup, data.getGraph()) ;
    
    
}
 
开发者ID:afs,项目名称:jena-inf-engine,代码行数:20,代码来源:DevRDFS.java


示例6: RelEx

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
public RelEx() {
	tokenizer = new Tokenizer();
	model = ModelFactory.createDefaultModel();
	model.setNsPrefix("rdfs", RDFS_NS);
	model.setNsPrefix("rdf", RDF_NS);
	model.setNsPrefix("owl", OWL_NS);
	model.setNsPrefix("dbpedia", DBPEDIA_NS);
	model.setNsPrefix("dbpedia-owl", DBPEDIA_OWL_NS);
	model.setNsPrefix("schema", SCHEMA_NS);
	model.setNsPrefix("wordnet-ontology", WORDNET_ONTOLOGY_NS);
	model.setNsPrefix("wn31", WN31_NS);
	
	final String wn31loc = System.getProperty("user.home") + "/wn31_tdb";
	log.info("Initializing WordNet 3.1 TDB database at {}", wn31loc);
	wn31tdb = TDBFactory.createDataset(wn31loc);
}
 
开发者ID:lumenrobot,项目名称:relex-id,代码行数:17,代码来源:RelEx.java


示例7: buildBaseDataset

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
private Dataset buildBaseDataset() {
	Dataset jenaData;
	
	if (StringUtils.isNotBlank(jenaConfig.getAssemblerFile())) {
		LOGGER.debug("Building dataset from assembler file {}", jenaConfig.getAssemblerFile());
		jenaData = DatasetFactory.assemble(jenaConfig.getAssemblerFile(), jenaConfig.getAssemblerDataset());
	} else if (StringUtils.isNotBlank(jenaConfig.getTdbPath())) {
		LOGGER.debug("Building dataset from TDB data at {}", jenaConfig.getTdbPath());
		jenaData = TDBFactory.createDataset(jenaConfig.getTdbPath());
	} else {
		LOGGER.debug("Building dataset from ontology URI {}", jenaConfig.getOntologyUri());
		FileManager fileManager = FileManager.get();
		Model model = fileManager.loadModel(jenaConfig.getOntologyUri());
		
		// Build the base dataset backed by the model loaded from the URI
		jenaData = DatasetFactory.create(model);
	}
	
	return jenaData;
}
 
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:21,代码来源:JenaOntologySearch.java


示例8: initialise

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
@Override
public void initialise(Map<String, Object> configuration) throws PluginInitialisationException {
	LOGGER.debug("Initialising ontology plugin: {}", PLUGIN_NAME);
	if (!configuration.containsKey(ENABLED_CFGKEY)) {
		LOGGER.info("No '{}' config key - assuming plugin disabled", ENABLED_CFGKEY);
	} else {
           enabled = (Boolean)configuration.get(ENABLED_CFGKEY);
           if (enabled) {
               if (!configuration.containsKey(TDB_PATH_CFGKEY)) {
                   throw new PluginInitialisationException("No " + TDB_PATH_CFGKEY + " specified - cannot create TDB dataset.");
               } else {
                   this.dataset = TDBFactory.createDatasetGraph((String) configuration.get(TDB_PATH_CFGKEY));
               }
           }
	}
}
 
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:17,代码来源:TDBOntologyPlugin.java


示例9: main

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
public static void main(String... argv)
{
    // Direct way: Make a TDB-back Jena model in the named directory.
    String directory = "MyDatabases/DB1" ;
    Dataset dataset = TDBFactory.createDataset(directory) ;
    
    // Potentially expensive query.
    String sparqlQueryString = "SELECT (count(*) AS ?count) { ?s ?p ?o }" ;
    // See http://incubator.apache.org/jena/documentation/query/app_api.html
    
    Query query = QueryFactory.create(sparqlQueryString) ;
    QueryExecution qexec = QueryExecutionFactory.create(query, dataset) ;
    try {
      ResultSet results = qexec.execSelect() ;
      for ( ; results.hasNext() ; )
      {
          QuerySolution soln = results.nextSolution() ;
          int count = soln.getLiteral("count").getInt() ;
          System.out.println("count = "+count) ;
      }
    } finally { qexec.close() ; }

    // Close the dataset.
    dataset.close();
    
}
 
开发者ID:xcurator,项目名称:xcurator,代码行数:27,代码来源:ExTDB5.java


示例10: main

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
public static void main(String... argv)
{
    // Direct way: Make a TDB-back Jena model in the named directory.
    String directory = "MyDatabases/DB1" ;
    Dataset dataset = TDBFactory.createDataset(directory) ;
    
    // Potentially expensive query.
    String sparqlQueryString = "SELECT (count(*) AS ?count) { ?s ?p ?o }" ;
    // See http://incubator.apache.org/jena/documentation/query/app_api.html
    
    Query query = QueryFactory.create(sparqlQueryString) ;
    QueryExecution qexec = QueryExecutionFactory.create(query, dataset) ;
    ResultSet results = qexec.execSelect() ;
    ResultSetFormatter.out(results) ;
    qexec.close() ;

    dataset.close();
}
 
开发者ID:xcurator,项目名称:xcurator,代码行数:19,代码来源:ExTDB4.java


示例11: main

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
public static void main(String... argv)
{
    DatasetGraphTransaction dsg = (DatasetGraphTransaction)TDBFactory.createDatasetGraph() ;

    // Start READ transaction. 
    dsg.begin(ReadWrite.READ) ;
    
    try
    {
        // Do some queries
        String sparqlQueryString1 = "SELECT (count(*) AS ?count) { ?s ?p ?o }" ;
        execQuery(sparqlQueryString1, dsg) ;
    } finally
    {
        dsg.end() ;
    }
}
 
开发者ID:xcurator,项目名称:xcurator,代码行数:18,代码来源:ExTDB_Txn3.java


示例12: SemaphoreModel

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
public SemaphoreModel(File tdbDirectory, String graphName, boolean resetTDB) throws IOException {
	if (resetTDB && tdbDirectory.exists()) {
		FileUtils.deleteDirectory(tdbDirectory);
	}
	Dataset dataset = TDBFactory.createDataset(tdbDirectory.getAbsolutePath());

	if  ((graphName == null) || (graphName.trim().length() == 0)) {
		model = dataset.getNamedModel(graphName);
	} else {
		model = dataset.getDefaultModel();
	}
	setPrefixes();
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:14,代码来源:SemaphoreModel.java


示例13: loadModelToTdb

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
/**
 * Fetch a model at the specified URI, load and return an TDB-backed Jena model.
 *
 * @param rdfUri
 * @param modelId
 * @param tDbDirectoryPath
 * @return
 */
public static Model loadModelToTdb(String rdfUri, String modelId, String tDbDirectoryPath) {

  if (logger.isDebugEnabled()) {
    logger.debug("RDF URI : {}", rdfUri);
    logger.debug("Model ID: {}", modelId);
    logger.debug("TDB  DIR: {}", tDbDirectoryPath);
  }

  Dataset dataset = TDBFactory.createDataset(tDbDirectoryPath);
  Model model = dataset.getNamedModel(modelId);
  TDBLoader.loadModel(model, rdfUri );
  return model;
}
 
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:22,代码来源:ModelLoader.java


示例14: queryData2

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
public static Boolean queryData2(String query){
	Dataset db = TDBFactory.createDataset("temp/dataset");
	db.begin(ReadWrite.READ);
    Model model = db.getDefaultModel();
    Query q = QueryFactory.create(query);
    QueryExecution qexec = QueryExecutionFactory.create(query, model);
    List<String> answer = new ArrayList<String>();
    Boolean t = (qexec.execAsk());
    qexec.close();
    db.close();
    return t;
}
 
开发者ID:kunal15595,项目名称:smart-question-answering-nlp,代码行数:13,代码来源:Database.java


示例15: main

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
public static void main(String... args) {
        //org.seaborne.delta.cmds.patchparse.main("/home/afs/tmp/X.rdfp");
        org.seaborne.delta.cmds.rdf2patch.main("/home/afs/tmp/D.ttl");
        System.exit(0);
        
//        FileOps.ensureDir("DB");
//        FileOps.clearAll("DB");
        DatasetGraph dsg = TDBFactory.createDatasetGraph();
        Txn.executeWrite(dsg,  ()->{});
        DatasetGraph dsg1 = new DatasetGraphOne(dsg.getDefaultGraph());
        DatasetGraph dsg2 = RDFPatchOps.textWriter(dsg1, System.out);
        
        Txn.executeWrite(dsg1,  ()->{});
        Txn.executeWrite(dsg2,  ()->{});
    }
 
开发者ID:afs,项目名称:rdf-delta,代码行数:16,代码来源:Run.java


示例16: localStorage

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
/** Create a dataset appropriate to the storage type.
     * This does <em>not</em> write the configuration details into the on-disk zone information.
     */
    public DatasetGraph localStorage(LocalStorageType storage, Path dataPath) {
        switch(storage) {
            case EXTERNAL:     return null;
            case MEM:          return DatasetGraphFactory.createTxnMem();
//            case NONE:         return null;
            case TDB:
                return TDBFactory.createDatasetGraph(IOX.asLocation(dataPath));
            default :
                throw new NotImplemented("Zone::localStorage = "+storage);
        }
    }
 
开发者ID:afs,项目名称:rdf-delta,代码行数:15,代码来源:Zone.java


示例17: empty

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
public void empty(Location location) {

		Dataset dataset = TDBFactory.createDataset(location);
		Iterator<String> namesIt = dataset.listNames();
		while (namesIt.hasNext()) {
			dataset.removeNamedModel(namesIt.next());
		}
	}
 
开发者ID:AnLiGentile,项目名称:cLODg,代码行数:9,代码来源:JenaTDBTriplestoreBuilder.java


示例18: setUpClass

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
/**
 *
 * @throws Exception
 */
@BeforeClass
public static void setUpClass() throws Exception {
    final String typeName = "JenaSourceType";
    if ( ! DataSourceTypesRegistry.isRegistered(typeName) ) {
        DataSourceTypesRegistry.register( typeName,
                                          new JenaTDBDataSourceType() );
    }

    String tmpdir = System.getProperty("java.io.tmpdir");
    jena = new File(tmpdir, "ldf-jena-test");
    jena.mkdir();
    
    dataset = TDBFactory.createDataset(jena.getAbsolutePath());

    Model model = dataset.getDefaultModel();
    InputStream in = ClassLoader.getSystemResourceAsStream("demo.nt");
    RDFDataMgr.read(model, in, Lang.NTRIPLES);
    model.commit();

    // Everything is in place, now create the LDF datasource                
    JsonObject config = createConfig("jena tdb test", "jena tdb test",
                                     typeName);
    
    JsonObject settings = new JsonObject();
    settings.addProperty("directory", jena.getAbsolutePath());
    config.add("settings", settings);

    setDatasource(DataSourceFactory.create(config));
}
 
开发者ID:LinkedDataFragments,项目名称:Server.Java,代码行数:34,代码来源:JenaTDBDataSourceTest.java


示例19: tearDownClass

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
/**
 *
 * @throws Exception
 */
@AfterClass
public static void tearDownClass() throws Exception {
    TDBFactory.release(dataset);
    File[] files = jena.listFiles();
    for (File f : files) {
        f.delete();
    }
    jena.delete();
 
}
 
开发者ID:LinkedDataFragments,项目名称:Server.Java,代码行数:15,代码来源:JenaTDBDataSourceTest.java


示例20: startup

import org.apache.jena.tdb.TDBFactory; //导入依赖的package包/类
@Override
public void startup(App app) {
    super.startup(app);

    if (tdbDir != null) {
        log.info("Opening database at tdbDir");
        dataset = TDBFactory.createDataset( tdbDir );
    } else {
        log.warn("Opening in-memory database");
        dataset = TDBFactory.createDataset( );
    }
    baseDataset = dataset;

    if (isUnionDefault) {
        // Nasty global side effect, in normal implementation this is done per query
        TDB.getContext().set(TDB.symUnionDefaultGraph, true) ;
    }
    
    if (timeout != null) {
        ARQ.getContext().set(ARQ.queryTimeout, timeout);
    }
    
    if (textIndex != null || indexSpec != null) {
        makeTextDataset();
    }        
    
    if (qEndpoint != null) {
        bindFusekiRef();
    }
}
 
开发者ID:UKGovLD,项目名称:registry-core,代码行数:31,代码来源:TDBStore.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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