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


Java TDBFactory.createDataset方法代码示例

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


在下文中一共展示了TDBFactory.createDataset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: main

import org.apache.jena.tdb.TDBFactory; //导入方法依赖的package包/类
public static void main(String... argv)
{
    String directory = "MyDatabases/DB1" ;
    Dataset dataset = TDBFactory.createDataset(directory) ;

    // Start WRITE transaction. 
    //   It's possible to read from the datet inside the write transaction.

    //   An application can have other Datasets, in the same JVM, 
    //   tied to the same TDB database performing read
    //   transactions concurrently. If another write transaction
    //   starts, the call of dataset.begin(WRITE) blocks until
    //   existing writer finishes.
    
    dataset.begin(ReadWrite.WRITE) ;
    try
    {
        GraphStore graphStore = GraphStoreFactory.create(dataset) ;
        // Do a SPARQL Update.
        String sparqlUpdateString = StrUtils.strjoinNL(
             "PREFIX . <http://example/>",
             "INSERT { :s :p ?now } WHERE { BIND(now() AS ?now) }"
             ) ;

        execUpdate(sparqlUpdateString, graphStore) ;
        dataset.commit() ;
        // Or call .abort()
        
    } finally
    {
        // Notify the end of the transaction.
        // The transaction was finished at the point .commit or .abort was called.
        // .end will force an abort() if no previous call to .commit() or .abort()
        // has occurred, so .end() help manage track the state of the transaction.
        // .end() can be called multiple times for the same .begin(WRITE)
        dataset.end() ;
    }
}
 
开发者ID:xcurator,项目名称:xcurator,代码行数:39,代码来源:ExTDB_Txn2.java


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