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


Java ModelFactory類代碼示例

本文整理匯總了Java中com.hp.hpl.jena.rdf.model.ModelFactory的典型用法代碼示例。如果您正苦於以下問題:Java ModelFactory類的具體用法?Java ModelFactory怎麽用?Java ModelFactory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: initializeCategories

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入依賴的package包/類
public Set<String> initializeCategories() {
	Model model = ModelFactory.createDefaultModel();
	model.read("/home/zwicklbauer/HDTGeneration/skos_categories_en.nt");
	StmtIterator it = model.listStatements();
	Set<String> set = new HashSet<String>();
	
	System.out.println("Los gehts");
	while (it.hasNext()) {
		Statement s = it.next();
		Resource r = s.getSubject();
		Property p = s.getPredicate();
		RDFNode n = s.getObject();
		if (p.getURI().equalsIgnoreCase(
				"http://www.w3.org/2004/02/skos/core#broader")
				&& n.isResource()) {
			Resource target = n.asResource();
			if(!hasSubCategory(target.getURI())) 
			set.add(target.getURI());
			if(!hasSubCategory(r.getURI())) 
			set.add(r.getURI());
		}
	}
	return set;
}
 
開發者ID:quhfus,項目名稱:DoSeR,代碼行數:25,代碼來源:DbpediaGraphModification.java

示例2: parse

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入依賴的package包/類
/**
 * Parse RDF input as string
 *
 * @param input RDF values as String
 * @return an {@link Request} object which contains information about latitude, longitude and date
 * @throws IllegalStateException if RDF is not literal
 * @throws NullPointerException  if input is null
 */
public static Request parse(String input) {
    Objects.requireNonNull(input);
    Model model = ModelFactory.createDefaultModel();
    model.read(new ByteArrayInputStream(input.getBytes()), null, "TURTLE");

    Map<String, Object> map = new HashMap<>();
    model.listStatements().forEachRemaining(statement -> {
        RDFNode rdfNode = statement.getObject();
        if (rdfNode.isLiteral()) {
            try {
                map.put(statement.getPredicate().getLocalName(), statement.getObject().asLiteral().getValue());
            } catch (Exception e) {
                LOGGER.error("RDF statement is not literal");
                throw new IllegalStateException(e.getMessage());
            }
        }
    });

    model.close();
    return getDataFromMap(map);
}
 
開發者ID:IKB4Stream,項目名稱:IKB4Stream,代碼行數:30,代碼來源:RDFParser.java

示例3: run

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入依賴的package包/類
@Test
public void run() {
	SystemLoader loader = new SystemLoader();
	loader.setJdbcURL(db.getJdbcURL());
	loader.setUsername(db.getUser());
	loader.setMappingFile(mappingFile);
	loader.setStartupSQLScript(sqlFile);
	loader.setSystemBaseURI(BASE_URI);
	if (resultFile == null) {
		R2RMLReader reader = loader.getR2RMLReader();
		MappingValidator validator = new MappingValidator(
				reader.getMapping(), loader.getSQLConnection());
		validator.setReport(reader.getReport());
		validator.run();
		if (!reader.getReport().hasError()) {
			fail("Expected validation error");
		}
		return;
	}
	Model actualTriples = ModelFactory.createDefaultModel();
	actualTriples.add(loader.getModelD2RQ());
	Model expectedTriples = FileManager.get().loadModel(resultFile, "N-TRIPLES");
	ModelAssert.assertIsomorphic(expectedTriples, actualTriples);
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:25,代碼來源:R2RMLTest.java

示例4: setUp

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入依賴的package包/類
public void setUp() {
	this.model = ModelFactory.createDefaultModel();
	this.mapping = new Mapping();
	this.database = new Database(this.model.createResource());
	this.mapping.addDatabase(this.database);
	
	concept = createClassMap("http://example.com/concept#@@[email protected]@");
	conceptTypeBridge = createPropertyBridge(concept, RDF.type.getURI());
	conceptTypeBridge.setConstantValue(model.createResource("http://www.w3.org/2004/02/skos/core#Concept"));
	
	collection = createConstantClassMap("http://example.com/collection#MyConceptCollection");
	collectionTypeBridge = createPropertyBridge(collection, RDF.type.getURI());
	collectionTypeBridge.setConstantValue(model.createResource("http://www.w3.org/2004/02/skos/core#Collection"));

	memberBridge = createPropertyBridge(collection, "http://www.w3.org/2004/02/skos/core#member");
	memberBridge.setRefersToClassMap(concept);
	memberBridge.addCondition("c.foo = 1");
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:19,代碼來源:ConstantValueClassMapTest.java

示例5: getTestListFromManifest

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入依賴的package包/類
public static Collection<Object[]> getTestListFromManifest(String manifestFileURL) {
		// We'd like to use FileManager.loadModel() but it doesn't work on jar: URLs
//		Model m = FileManager.get().loadModel(manifestFileURL);
		Model m = ModelFactory.createDefaultModel();
		m.read(manifestFileURL, "TURTLE");

		IRI baseIRI = D2RQTestUtil.createIRI(m.getNsPrefixURI("base"));
		ResultSet rs = QueryExecutionFactory.create(TEST_CASE_LIST, m).execSelect();
		List<Object[]> result = new ArrayList<Object[]>();
		while (rs.hasNext()) {
			QuerySolution qs = rs.next();
			Resource mapping = qs.getResource("mapping");
			Resource schema = qs.getResource("schema");
//			if (!mapping.getLocalName().equals("constant-object.ttl")) continue;
			QueryExecution qe = QueryExecutionFactory.create(TEST_CASE_TRIPLES, m);
			qe.setInitialBinding(qs);
			Model expectedTriples = qe.execConstruct();
			result.add(new Object[]{baseIRI.relativize(mapping.getURI()).toString(), mapping.getURI(), 
					schema.getURI(), expectedTriples});
		}
		return result;
	}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:23,代碼來源:ProcessorTestBase.java

示例6: reload

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入依賴的package包/類
private void reload() {
	loader.getMapping().connect();
	GraphD2RQ graph = loader.getGraphD2RQ();
	
	datasetGraph = DatasetGraphFactory.createOneGraph(graph);
	defaultModel = ModelFactory.createModelForGraph(datasetGraph.getDefaultGraph());		

	hasTruncatedResults = false;
	for (Database db: loader.getMapping().databases()) {
		if (db.getResultSizeLimit() != Database.NO_LIMIT) {
			hasTruncatedResults = true;
		}
	}

	if (autoReload) {
		lastModified = watchedFile.lastModified();
		lastReload = System.currentTimeMillis();
	}
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:20,代碼來源:AutoReloadableDataset.java

示例7: setUp

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入依賴的package包/類
public void setUp() {
	this.model = ModelFactory.createDefaultModel();
	this.mapping = new Mapping();
	this.database = new Database(this.model.createResource());
	database.useConnectedDB(new DummyDB());
	this.mapping.addDatabase(this.database);

	employees = createClassMap("http://test/[email protected]@[email protected]@");
	employees.addAlias("employees AS e");
	employees.addJoin("e.ID = foo.bar");
	employees.addCondition("e.status = 'active'");
	managerBridge = createPropertyBridge(employees, "http://terms.example.org/manager");
	managerBridge.addAlias("e AS m");
	managerBridge.setRefersToClassMap(this.employees);
	managerBridge.addJoin("e.manager = m.ID");
	
	cities = createClassMap("http://test/[email protected]@[email protected]@");
	citiesTypeBridge = createPropertyBridge(cities, RDF.type.getURI());
	citiesTypeBridge.setConstantValue(model.createResource("http://terms.example.org/City"));
	citiesNameBridge = createPropertyBridge(cities, "http://terms.example.org/name");
	citiesNameBridge.setColumn("c.name");
	countries = createClassMap("http://test/countries/@@[email protected]@");
	countries.setContainsDuplicates(true);
	countriesTypeBridge = createPropertyBridge(countries, RDF.type.getURI());
	countriesTypeBridge.setConstantValue(model.createResource("http://terms.example.org/Country"));
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:27,代碼來源:CompileTest.java

示例8: toRdf

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入依賴的package包/類
/**
 * Convert a PhenoPacket to RDF triples using the JSON-LD context
 * 
 * @param packet
 * @param base
 *            URI base for generated RDF; if `null` a UUID-based base will
 *            be used
 * @return model containing RDF triples
 * @throws JsonLdError
 * @throws JsonProcessingException
 */
public static Model toRdf(PhenoPacket packet, String base)
		throws JsonLdError, JsonProcessingException {
	PhenoPacket packetWithContext;
	if (packet.getContext() == null) {
		packetWithContext = PhenoPacket.newBuilder(packet)
                           .context(ContextUtil.defaultContextURI)
                           .build();
	} else {
		packetWithContext = packet;
	}
	Model rdfModel = ModelFactory.createDefaultModel();
	StringReader reader = new StringReader(
			JsonGenerator.render(packetWithContext));
	String baseToUse;
	if (base != null) {
		baseToUse = base;
	} else {
		String uuid = UUID.randomUUID().toString();
		baseToUse = "http://phenopackets.org/local/" + uuid + "/";
	}
	RDFDataMgr.read(rdfModel, reader, baseToUse, Lang.JSONLD);
	return rdfModel;
}
 
開發者ID:phenopackets,項目名稱:phenopacket-reference-implementation,代碼行數:35,代碼來源:RdfGenerator.java

示例9: loadDefaultRules

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入依賴的package包/類
private static Model loadDefaultRules(){
	Model rules=ModelFactory.createDefaultModel();
	rules.add(SPIN.getModel());
	rules.add(SP.getModel());
	InputStream in=BimSPARQL.class.getClassLoader().getResourceAsStream("bimsparql/schm.ttl"); //new FileInputStream("IFC2X3_Schema.rdf");
	rules.read(in, null,"TTL");
	InputStream in2=BimSPARQL.class.getClassLoader().getResourceAsStream("bimsparql/pset.ttl"); //new FileInputStream("IFC2X3_Schema.rdf");
	rules.read(in2, null,"TTL");
	InputStream in3=BimSPARQL.class.getClassLoader().getResourceAsStream("bimsparql/pdt.ttl"); //new FileInputStream("IFC2X3_Schema.rdf");
	rules.read(in3, null,"TTL");
	InputStream in4=BimSPARQL.class.getClassLoader().getResourceAsStream("bimsparql/qto.ttl"); //new FileInputStream("IFC2X3_Schema.rdf");
	rules.read(in4, null,"TTL");
	InputStream in5=BimSPARQL.class.getClassLoader().getResourceAsStream("bimsparql/geom.ttl"); //new FileInputStream("IFC2X3_Schema.rdf");
	rules.read(in5, null,"TTL");
	InputStream in6=BimSPARQL.class.getClassLoader().getResourceAsStream("bimsparql/spt.ttl"); //new FileInputStream("IFC2X3_Schema.rdf");
	rules.read(in6, null,"TTL");
	return rules;
}
 
開發者ID:BenzclyZhang,項目名稱:BimSPARQL,代碼行數:19,代碼來源:BimSPARQL.java

示例10: loadDefaultModel

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入依賴的package包/類
public static OntModel loadDefaultModel(){
	InputStream in = BodyGeometryTest.class.getClassLoader()
			.getResourceAsStream("Duplex_A_20110505.ttl");
	Model model=ModelFactory.createDefaultModel();
	model.read(in,null,"TTL");
	InputStream ins = BodyGeometryTest.class.getClassLoader()
			.getResourceAsStream("IFC2X3_TC1.ttl");
	InputStream input = BodyGeometryTest.class.getClassLoader()
			.getResourceAsStream("Duplex_A_20110505_geometry.ttl");
	Model geometryModel=ModelFactory.createDefaultModel();
	geometryModel.read(input,null,"TTL");
	Model schema=ModelFactory.createDefaultModel();
	schema.read(ins,null,"TTL");	
		try {
			BimSPARQL.init(model,geometryModel);
		} catch (ClassNotFoundException | IOException | ParserConfigurationException | SAXException
				| URISyntaxException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	OntModel ontology=ModelFactory.createOntologyModel();
	ontology.add(schema);
	ontology.add(model);
	ontology.add(geometryModel);
	return ontology;
}
 
開發者ID:BenzclyZhang,項目名稱:BimSPARQL,代碼行數:27,代碼來源:QueryFunctionTest.java

示例11: loadIbcData

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入依賴的package包/類
public static Model loadIbcData(){
	Model table=loadModel("Table_705.8.ttl","TTL");
	Model tableFunction=loadModel("Table_705.8_Function.ttl","TTL");
	Model qudtExpr=loadModel("QudtExpr.ttl","TTL");
	Model qudtSpin=loadModel("http://www.qudt.org/qudt/owl/1.0.0/qudt-spin.owl",null);
	Model unit=loadModel("http://www.qudt.org/qudt/owl/1.0.0/unit.owl",null);
	Model union=ModelFactory.createDefaultModel();
	Model spModel = SP.getModel();
	Model spinModel = SPIN.getModel();
	union.add(table);
	union.add(tableFunction);
	union.add(qudtExpr);
	union.add(qudtSpin);
	union.add(unit);
	union.add(spModel);
	union.add(spinModel);
	return union;
}
 
開發者ID:BenzclyZhang,項目名稱:BimSPARQL,代碼行數:19,代碼來源:FireSeparationDistance.java

示例12: sendRequest

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入依賴的package包/類
/***************************************************************************
 * Private Methods - Handle Translation
 **************************************************************************/

private Model sendRequest(HttpServletRequest req, String url)
    throws ResponseThrowable
{
    HttpClient client = new HttpClient();
    GetMethod  method = new GetMethod(url);
    method.setRequestHeader("Accept-Encoding", "gzip");
    method.setRequestHeader("Accept"         , _format.getMimetype());
    InputStream is = null;
    try {
        int rspCode = client.executeMethod(method);
        if ( rspCode != 200 ) { throw new ResponseThrowable(rspCode); }

        is = getInputStream(method);
        Model m = ModelFactory.createDefaultModel();
        m.read(is, null, _format.getJenaFormat().getLang().getLabel());
        return m;
    }
    catch (RiotException | IOException e) {
        throw new ResponseThrowable(e, 502);
    }
    finally { IOUtils.closeQuietly(is); method.releaseConnection(); }
}
 
開發者ID:hugomanguinhas,項目名稱:europeana,代碼行數:27,代碼來源:FormatHandlerServlet.java

示例13: writeUserEntries

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入依賴的package包/類
/**
 * Writes the user entities to rdf
 */
private static OntModel writeUserEntries() {
	OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
	try {
		thewebsemantic.Bean2RDF writer = new Bean2RDF(model);
		InitialContext ic = new InitialContext();
		UserService userService = (UserService) ic.lookup("java:module/UserService");
		List<User> users = userService.getAll();
		for (User u : users) {
			writer.save(u);
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return model;
}
 
開發者ID:U-QASAR,項目名稱:u-qasar.platform,代碼行數:19,代碼來源:UQasarUtil.java

示例14: process

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入依賴的package包/類
public void process(File src, File all, File dst, File enrich) throws IOException
{
    Model m = ModelFactory.createDefaultModel();
    loadFiles(src, ".xml", m);

    storeAsEDM(m, all);

    _type      = m.getProperty(RDF_TYPE);
    _prefLabel = m.getProperty(SKOS_PREF_LABEL);
    _foafName  = m.getProperty(FOAF_NAME);
    Resource pcho = m.getResource(EDM_PROVIDEDCHO);

    CSVWriter printer = new CSVWriter(enrich, CSVFormat.EXCEL);
    printer.start();
    try {
        enrichImpl(m.listSubjectsWithProperty(_type, pcho), printer);
    }
    finally {
        printer.end();
    }

    storeAsEDM(m, dst);

    new CHOAnalysis().analyse(dst);
}
 
開發者ID:hugomanguinhas,項目名稱:europeana,代碼行數:26,代碼來源:DatasetProcessor.java

示例15: merge

import com.hp.hpl.jena.rdf.model.ModelFactory; //導入依賴的package包/類
public void merge(File src, File dst) throws IOException
{
	Model m = ModelFactory.createDefaultModel();
	m.setNsPrefix("cc", "http://creativecommons.org/ns#");
	m.setNsPrefix("dc", "http://purl.org/dc/elements/1.1/");
	m.setNsPrefix("dcterms", "http://purl.org/dc/terms/");
	m.setNsPrefix("edm", "http://www.europeana.eu/schemas/edm/");
	m.setNsPrefix("foaf", "http://xmlns.com/foaf/0.1/");
	m.setNsPrefix("odrl", "http://www.w3.org/ns/odrl/2/");
	m.setNsPrefix("ore", "http://www.openarchives.org/ore/terms/");
	m.setNsPrefix("owl", "http://www.w3.org/2002/07/owl#");
	m.setNsPrefix("rdaGr2", "http://rdvocab.info/ElementsGr2/");
	m.setNsPrefix("skos", "http://www.w3.org/2004/02/skos/core#");
	m.setNsPrefix("wgs84_pos", "http://www.w3.org/2003/01/geo/wgs84_pos#");
	m.setNsPrefix("xsi", "http://www.w3.org/2001/XMLSchema-instance");
	m.setNsPrefix("xml", "http://www.w3.org/XML/1998/namespace");

	merge(src, m);
	//store(m, dst, "RDF/XML-ABBREV");
	store(m, dst, "RDF/XML");
}
 
開發者ID:hugomanguinhas,項目名稱:europeana,代碼行數:22,代碼來源:MergeRDFDatasets.java


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