當前位置: 首頁>>代碼示例>>Java>>正文


Java Dataset.getDefaultModel方法代碼示例

本文整理匯總了Java中com.hp.hpl.jena.query.Dataset.getDefaultModel方法的典型用法代碼示例。如果您正苦於以下問題:Java Dataset.getDefaultModel方法的具體用法?Java Dataset.getDefaultModel怎麽用?Java Dataset.getDefaultModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.hp.hpl.jena.query.Dataset的用法示例。


在下文中一共展示了Dataset.getDefaultModel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadData

import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
/**
 * Import the data into the data set. When a new data set is imported the old data is deleted. 
 * @param dataset
 * @param file
 */
public void loadData(Dataset dataset, String file){
    log.info("Start loading") ;
    long startTime = System.nanoTime() ;
    dataset.begin(ReadWrite.WRITE) ;
    try {
        Model m = dataset.getDefaultModel() ;
        log.info("Number of triples before loading: " + m.size());
        RDFDataMgr.read(m, file) ;
        log.info("Number of triples after loading: " + m.size());
        dataset.commit() ;
    } 
    finally { 
        dataset.end() ;
    }
    long finishTime = System.nanoTime() ;
    double time = (finishTime-startTime)/1.0e6 ;
    log.info(String.format("Finish loading - %.2fms", time)) ;
}
 
開發者ID:fusepoolP3,項目名稱:p3-osm-transformer,代碼行數:24,代碼來源:JenaTextConfig.java

示例2: TDBloading

import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
/**
 * Load jena TDB
 */
private void TDBloading(){

	logger.info("TDB loading");

	// create model from tdb
	Dataset dataset = TDBFactory.createDataset(tdbDirectory);

	// assume we want the default model, or we could get a named model here
	dataset.begin(ReadWrite.READ);
	model = dataset.getDefaultModel();
	dataset.end() ;

	// if model is null load local dataset into jena TDB
	if(model == null)
		TDBloading(datasetFile);

}
 
開發者ID:sisinflab,項目名稱:lodreclib,代碼行數:21,代碼來源:RDFTripleExtractor.java

示例3: demoOfReadTransaction

import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
private static void demoOfReadTransaction(Dataset dataset) {
	dataset.begin(ReadWrite.READ);

	// Get model inside the transaction
	Model model = dataset.getDefaultModel();

	// query the inserted facts
	StringBuilder query = SPARQLUtils.getRegualrSPARQLPREFIX();
	query.append("PREFIX foaf: <http://xmlns.com/foaf/0.1/>").append(Constants.NEWLINE);
	query.append("SELECT DISTINCT ?person WHERE {?person rdf:type foaf:Person}");
	SPARQLUtils.query(model, query.toString(), "?person");

	model.close();// closing the model to flush

	dataset.end();
}
 
開發者ID:zhoujiagen,項目名稱:Jena-Based-Semantic-Web-Tutorial,代碼行數:17,代碼來源:TDBManipulation.java

示例4: demoOfWriteTransaction

import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
private static void demoOfWriteTransaction(Dataset dataset) {
	dataset.begin(ReadWrite.WRITE);

	Model model = dataset.getDefaultModel();

	ModelUtils.fillModel(model, FOAF_BASE_URI, FOAF_SCHEMA_FilePath);

	// insert foaf:me rdf:type foaf:Person
	Resource me = model.createResource(FOAF_BASE_URI + "me");
	Property rdfType = model.getProperty(Constants.RDF_TYPE_URL);
	Resource FOAFPersonClass = model.getResource(FOAF_BASE_URI + "Person");
	model.add(me, rdfType, FOAFPersonClass);
	// model.write(System.out);// for debug

	model.close();// closing the model to flush

	dataset.commit();

	dataset.end();
}
 
開發者ID:zhoujiagen,項目名稱:Jena-Based-Semantic-Web-Tutorial,代碼行數:21,代碼來源:TDBManipulation.java

示例5: inferMissingPropertyNames

import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
@Test
public void inferMissingPropertyNames() throws Exception {
  final Dataset ds = TDBFactory.createDataset();
  final DatasetPopulator dsp = new DatasetPopulator(ds);
  dsp.addModel(loadModel("infer-property-names/data.ttl"));

  final Model x = loadModel("infer-property-names/expected.ttl");

  ds.begin(ReadWrite.READ);

  try {
    final Model m = ds.getDefaultModel();
    assertTrue(m.containsAll(x));
  } finally {
    ds.end();
  }
}
 
開發者ID:ewie,項目名稱:cobalt,代碼行數:18,代碼來源:DatasetPopulatorTest.java

示例6: test_rdfcreation_fb

import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
@Test
public void test_rdfcreation_fb() throws SAXException, IOException, ParserConfigurationException, Exception {

    Document dataDoc = parser.parse(RdfFactoryTest.class.getResourceAsStream(
            "/data/fb-20121231.xml"), -1);

    RdfFactory factory = new RdfFactory(new RunConfig(domain));
    factory.createRdfs(dataDoc, testTdbDir);

    Dataset dataset = TDBFactory.createDataset(testTdbDir);
    dataset.begin(ReadWrite.READ);
    Model model = dataset.getDefaultModel();
    Assert.assertFalse("No RDF was generated. TDB directory: " + testTdbDir, model.isEmpty());

    dataset.end();
}
 
開發者ID:ekzhu,項目名稱:xbrl2rdf,代碼行數:17,代碼來源:RdfFactoryTest.java

示例7: test_rdfcreation_msft

import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
@Test
public void test_rdfcreation_msft() throws SAXException, IOException, ParserConfigurationException, Exception {

    Document dataDoc = parser.parse(RdfFactoryTest.class.getResourceAsStream(
            "/data/msft-20130630.xml"), -1);

    RdfFactory factory = new RdfFactory(new RunConfig(domain));
    factory.createRdfs(dataDoc, testTdbDir);

    Dataset dataset = TDBFactory.createDataset(testTdbDir);
    dataset.begin(ReadWrite.READ);
    Model model = dataset.getDefaultModel();
    Assert.assertFalse("No RDF was generated. TDB directory: " + testTdbDir, model.isEmpty());

    dataset.end();
}
 
開發者ID:ekzhu,項目名稱:xbrl2rdf,代碼行數:17,代碼來源:RdfFactoryTest.java

示例8: doit

import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
public void doit() {
	Dataset dataset = DatasetFactory.createMem();
	
	Model model = dataset.getDefaultModel();
	model.read("category_labels_en.nq");
	if (model.READ){
		System.out.println("right!!");
	}
	Query q = QueryFactory.create(query);
	QueryExecution qe = QueryExecutionFactory.create(q, model);
	ResultSet rs = qe.execSelect();
	ResultSetFormatter.out(rs);
	
	

}
 
開發者ID:SaudAljaloud,項目名稱:RdfLiteralStats,代碼行數:17,代碼來源:NquadsTest.java

示例9: createModel

import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
public static Model createModel(String... dbDirs) {
	Model mainModel = null; 
	Dataset dataset = null;
	for(String dbDir : dbDirs) {
		dataset = TDBFactory.createDataset(dbDir);
		if(mainModel == null) {
			mainModel = dataset.getDefaultModel();				
		} else {
			Model secondaryModel = dataset.getDefaultModel();
			mainModel = ModelFactory.createUnion(mainModel, secondaryModel);
		}
	}
	mainModel = ModelFactory.createRDFSModel(mainModel);
	return mainModel;
}
 
開發者ID:AKSW,項目名稱:KBox,代碼行數:16,代碼來源:TDB.java

示例10: perspectiveRelationsToTrig

import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
public static void perspectiveRelationsToTrig (String pathToTrigFile, ArrayList<PerspectiveObject> perspectiveObjects) {
    try {
        OutputStream fos = new FileOutputStream(pathToTrigFile);
        Dataset ds = TDBFactory.createDataset();
        Model defaultModel = ds.getDefaultModel();
        ResourcesUri.prefixModel(defaultModel);
      //  Model provenanceModel = ds.getNamedModel("http://www.newsreader-project.eu/perspective");
        ResourcesUri.prefixModelGaf(defaultModel);
        JenaSerialization.addJenaPerspectiveObjects(ds, perspectiveObjects);
        RDFDataMgr.write(fos, ds, RDFFormat.TRIG_PRETTY);
        fos.close();
    } catch (IOException e) {
        e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
    }
}
 
開發者ID:newsreader,項目名稱:StreamEventCoreference,代碼行數:16,代碼來源:GetPerspectiveRelations.java

示例11: perspectiveRelationsToTrigStream

import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
public static void perspectiveRelationsToTrigStream (OutputStream fos, ArrayList<PerspectiveObject> perspectiveObjects) {

                Dataset ds = TDBFactory.createDataset();
                Model defaultModel = ds.getDefaultModel();
                ResourcesUri.prefixModel(defaultModel);
              //  Model provenanceModel = ds.getNamedModel("http://www.newsreader-project.eu/perspective");
                ResourcesUri.prefixModelGaf(defaultModel);
                JenaSerialization.addJenaPerspectiveObjects(ds, perspectiveObjects);
                RDFDataMgr.write(fos, ds, RDFFormat.TRIG_PRETTY);
    }
 
開發者ID:newsreader,項目名稱:StreamEventCoreference,代碼行數:11,代碼來源:GetPerspectiveRelations.java

示例12: testOsmData

import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
@Test
public void testOsmData() throws TransformerConfigurationException, FileNotFoundException, 
                                  TransformerException, IOException {
	InputStream xmlIn = getClass().getResourceAsStream("giglio_island.osm");
	InputStream xslIn = getClass().getResourceAsStream("/osm-way-node-keys.xsl");
	InputStream rdfIn = processor.processXml(xslIn, xmlIn, locationHeader);
	Dataset jenads = DatasetFactory.createMem() ;
	Model graph = jenads.getDefaultModel();		
	RDFDataMgr.read(graph, rdfIn, null, Lang.TURTLE);
	Property streetAddress = graph.createProperty("http://schema.org/streetAddress");
	StmtIterator istmt = graph.listStatements(null, streetAddress, (RDFNode) null);
	Assert.assertTrue(istmt.hasNext());
	
}
 
開發者ID:fusepoolP3,項目名稱:p3-osm-transformer,代碼行數:15,代碼來源:XsltProcessorImplTest.java

示例13: getDefaultModel

import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
/**
 * get default model of dataset
 * 
 * @param dataset
 * @return
 */
public static final Model getDefaultModel(Dataset dataset) {
	if (dataset == null) {
		return null;
	}

	return dataset.getDefaultModel();
}
 
開發者ID:zhoujiagen,項目名稱:Jena-Based-Semantic-Web-Tutorial,代碼行數:14,代碼來源:DatasetUtils.java

示例14: main

import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
/** 
	 * Starts this client.
	 * 
	 * @param args the command line arguments.
	 */   
	public static void main(final String[] args) { 
		StorageLayerFactory factory = null; 
		Dataset dataset; 
		QueryExecution execution = null; 
		try {  
			factory = StorageLayerFactory.getFactory();
			dataset = DatasetFactory.create(factory.getDatasetGraph());
			
			Model model = dataset.getDefaultModel(); 
			model.read(new FileReader(new File("/home/agazzarini/Desktop/triples_dogfood.nt")), "http://ba.s.d", "N-TRIPLE");
			
			System.out.println(model.size());
			
//			Thread.sleep(1000);
			 
//			String q = 
//					"PREFIX : <http://learningsparql.com/ns/papers#> " +
//					"PREFIX c: <http://learningsparql.com/ns/citations#> " +
//					"SELECT ?s " + 
//					"WHERE { ?s c:cites :paperA . }";
//			
//			final Query query = QueryFactory.create(q);
//			execution = QueryExecutionFactory.create(query, model);
//			
//			ResultSet rs = execution.execSelect();
//			
//			System.out.println(ResultSetFormatter.asText(rs));
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (execution != null) execution.close();
			factory.getClientShutdownHook().close();
		}
	}
 
開發者ID:spaziocodice,項目名稱:jena-nosql,代碼行數:40,代碼來源:SimpleTestClient.java

示例15: main

import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
public static void main(String[] args) 
{
	Dataset dataset = TDBFactory.createDataset( "jenastore/triples" );
	
	Model model = dataset.getDefaultModel();
	
	StmtIterator sIter = model.listStatements();
	
	while( sIter.hasNext())
	{
		Statement s = sIter.next();
		System.out.println( "s: " + s.toString() );
	}
	
}
 
開發者ID:fogbeam,項目名稱:JenaTutorial,代碼行數:16,代碼來源:ReadTDBTriplestore.java


注:本文中的com.hp.hpl.jena.query.Dataset.getDefaultModel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。