本文整理汇总了Java中com.hp.hpl.jena.ontology.Ontology类的典型用法代码示例。如果您正苦于以下问题:Java Ontology类的具体用法?Java Ontology怎么用?Java Ontology使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Ontology类属于com.hp.hpl.jena.ontology包,在下文中一共展示了Ontology类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getBaseUriOfModel
import com.hp.hpl.jena.ontology.Ontology; //导入依赖的package包/类
private String getBaseUriOfModel(OntModel model) {
String modelBaseUri = null;
Set<String> importuris = model.listImportedOntologyURIs(true);
ExtendedIterator<Ontology> ontItr = model.listOntologies();
if (ontItr.hasNext()) {
while (ontItr.hasNext()) {
Ontology ont = ontItr.next();
if (modelBaseUri == null) {
modelBaseUri = ont.getURI(); // first is default incase imports are circular
}
if (!importuris.contains(ont.getURI())) {
modelBaseUri = ont.getURI();
break;
}
}
}
return modelBaseUri;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:19,代码来源:JenaReasonerPlugin.java
示例2: listSubModelsAndPrefixes
import com.hp.hpl.jena.ontology.Ontology; //导入依赖的package包/类
private Map<String, String> listSubModelsAndPrefixes(Map<String, String> map, OntModel m, String modelUri) {
Ontology onto = m.getOntology(modelUri);
if (onto != null) {
String prefix = m.getNsURIPrefix(modelUri);
if (prefix == null) {
prefix = getGlobalPrefix(modelUri);
}
if (!map.containsKey(modelUri)) {
map.put(modelUri, prefix);
}
ExtendedIterator<OntResource> importsItr = onto.listImports();
if (importsItr.hasNext()) {
while (importsItr.hasNext()) {
OntResource or = importsItr.next();
logger.debug("Ontology of model '" + modelUri + "' has import '" + or.toString() + "' with prefix '" + prefix + "'");
if (!map.containsKey(or.toString())) {
OntModel submodel = m.getImportedModel(or.getURI());
if (submodel != null) {
map = listSubModelsAndPrefixes(map, submodel, or.getURI());
}
}
}
}
}
return map;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:27,代码来源:ConfigurationManager.java
示例3: getImports
import com.hp.hpl.jena.ontology.Ontology; //导入依赖的package包/类
public synchronized Map<String, String> getImports(String publicUri, Scope scope) throws ConfigurationException, IOException {
OntModel theModel = getOntModel(publicUri, scope);
if (theModel != null) {
Ontology onto = theModel.getOntology(publicUri);
if (onto != null) {
ExtendedIterator<OntResource> importsItr = onto.listImports();
if (importsItr.hasNext()) {
Map<String, String> map = new HashMap<String, String>();
while (importsItr.hasNext()) {
OntResource or = importsItr.next();
String importUri = or.toString();
String prefix = theModel.getNsURIPrefix(importUri);
if (prefix == null) {
prefix = getGlobalPrefix(importUri);
}
logger.debug("Ontology of model '" + publicUri + "' has import '" + importUri + "' with prefix '" + prefix + "'");
if (!map.containsKey(importUri)) {
map.put(importUri, prefix);
}
}
return map;
}
}
}
return Collections.emptyMap();
}
开发者ID:crapo,项目名称:sadlos2,代码行数:27,代码来源:ConfigurationManagerForIDE.java
示例4: getBaseUriOfModel
import com.hp.hpl.jena.ontology.Ontology; //导入依赖的package包/类
private String getBaseUriOfModel(OntModel model) {
String modelBaseUri = null;
Set<String> importuris = model.listImportedOntologyURIs(true);
ExtendedIterator<Ontology> ontItr = model.listOntologies();
if (ontItr.hasNext()) {
while (ontItr.hasNext()) {
Ontology ont = ontItr.next();
if (modelBaseUri == null) {
modelBaseUri = ont.getURI(); // first is default in case imports are circular
}
if (!importuris.contains(ont.getURI())) {
modelBaseUri = ont.getURI();
break;
}
}
}
return modelBaseUri;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:19,代码来源:JenaReasonerPlugin.java
示例5: addImportToJenaModel
import com.hp.hpl.jena.ontology.Ontology; //导入依赖的package包/类
private void addImportToJenaModel(String modelName, String importUri, String importPrefix, Model importedOntModel) {
getTheJenaModel().getDocumentManager().addModel(importUri, importedOntModel, true);
Ontology modelOntology = getTheJenaModel().createOntology(modelName);
if (importPrefix == null) {
try {
importPrefix = getConfigMgr(getCurrentResource(), getOwlModelFormat(getProcessorContext()))
.getGlobalPrefix(importUri);
} catch (ConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (importPrefix != null) {
getTheJenaModel().setNsPrefix(importPrefix, importUri);
}
com.hp.hpl.jena.rdf.model.Resource importedOntology = getTheJenaModel().createResource(importUri);
modelOntology.addImport(importedOntology);
getTheJenaModel().addSubModel(importedOntModel);
getTheJenaModel().addLoadedImport(importUri);
addOrderedImport(importUri);
}
开发者ID:crapo,项目名称:sadlos2,代码行数:22,代码来源:JenaBasedSadlModelProcessor.java
示例6: prepareNewModel
import com.hp.hpl.jena.ontology.Ontology; //导入依赖的package包/类
private void prepareNewModel(int arraypos) throws ConfigurationException {
getModel(arraypos).setNsPrefixes(getImportModel().getNsPrefixMap());
Ontology ontology = null;
getModel(arraypos).setNsPrefix("", getModelNamespace());
ontology = getModel(arraypos).createOntology(importModelNS);
ontology.addComment("This ontology was created from a CSV data source.", "en");
for (int i = 0; imports != null && i < imports.length; i++) {
String rawImport = imports[i];
String publicUri = null;
if (rawImport.toLowerCase().startsWith(HTTP_URI_SCHEME)) {
publicUri = rawImport;
}
Resource importedOntology = getModel(arraypos).createResource(publicUri);
getModel(arraypos).getOntology(importModelNS).addImport(importedOntology);
if (owlModelFormat.equals(IConfigurationManager.JENA_TDB)) {
getModel(arraypos).add(getImportModel());
}
else {
// TODO : this will need to change for SadlServer/SadlServerPlus (awc, 5/28/2012)
if (incremental) {
IConfigurationManager cmgr = getConfigMgr();
if (cmgr != null) {
String alturl = cmgr.getAltUrlFromPublicUri(importModelNS);
if (alturl != null) {
getModel(arraypos).getDocumentManager().setProcessImports(true);
try {
getModel(arraypos).read(alturl);
}
catch (Throwable t) {
// this is ok if there is no previous import
}
}
}
}
getModel(arraypos).loadImports();
}
}
}
开发者ID:crapo,项目名称:sadlos2,代码行数:40,代码来源:CsvImporter.java
示例7: createInstanceModel
import com.hp.hpl.jena.ontology.Ontology; //导入依赖的package包/类
private OntModel createInstanceModel(String thisModelName)
throws IOException,
ConfigurationException {
if (instanceDataModels != null && instanceDataModels.containsKey(thisModelName)) {
return instanceDataModels.get(thisModelName);
}
if (editedTboxModels != null && editedTboxModels.containsKey(thisModelName)) {
return editedTboxModels.get(thisModelName);
}
OntModel model = ModelFactory.createOntologyModel(getConfigurationMgr().getOntModelSpec(null));
model.getDocumentManager().setFileManager(getConfigurationMgr().getJenaDocumentMgr().getFileManager());
Resource importOnt = model.getResource(getModelName());
Ontology ont = model.createOntology(thisModelName);
ont.addImport(importOnt);
ont.addComment("This ontology model was created by SadlServerPE.", "en");
model.getDocumentManager().setProcessImports(true);
model.loadImports();
// if (logger.isDebugEnabled()) {
Iterator<String> importItr = model.listImportedOntologyURIs().iterator();
while (importItr.hasNext()) {
// logger.debug("Model '" + thisModelName + "' imports '" + importItr.next() + "'");
System.out.println("Model '" + thisModelName + "' imports '" + importItr.next() + "'");
}
// }
model.getDocumentManager().setProcessImports(false);
if (instanceDataModels == null) {
instanceDataModels = new HashMap<String, OntModel>();
}
instanceDataModels.put(thisModelName, model);
return model;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:32,代码来源:SadlServerPEImpl.java
示例8: addOntology
import com.hp.hpl.jena.ontology.Ontology; //导入依赖的package包/类
public boolean addOntology(Ontology ontology) {
if (!ontologies.contains(ontology)) {
ontologies.add(ontology);
return true;
}
return false;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:8,代码来源:OwlToSadl.java
示例9: processModelImports
import com.hp.hpl.jena.ontology.Ontology; //导入依赖的package包/类
protected void processModelImports(Ontology modelOntology, URI importingResourceUri, SadlModel model)
throws OperationCanceledError {
EList<SadlImport> implist = model.getImports();
Iterator<SadlImport> impitr = implist.iterator();
while (impitr.hasNext()) {
SadlImport simport = impitr.next();
SadlModel importedResource = simport.getImportedResource();
if (importedResource != null) {
// URI importingResourceUri = resource.getURI();
String importUri = importedResource.getBaseUri();
String importPrefix = simport.getAlias();
Resource eResource = importedResource.eResource();
if (eResource instanceof XtextResource) {
XtextResource xtrsrc = (XtextResource) eResource;
URI importedResourceUri = xtrsrc.getURI();
OntModel importedOntModel = OntModelProvider.find(xtrsrc);
if (importedOntModel == null) {
logger.debug("JenaBasedSadlModelProcessor failed to resolve null OntModel for Resource '"
+ importedResourceUri + "' while processing Resource '" + importingResourceUri + "'");
} else {
addImportToJenaModel(modelName, importUri, importPrefix, importedOntModel);
}
} else if (eResource instanceof ExternalEmfResource) {
ExternalEmfResource emfResource = (ExternalEmfResource) eResource;
addImportToJenaModel(modelName, importUri, importPrefix, emfResource.getOntModel());
}
}
}
}
开发者ID:crapo,项目名称:sadlos2,代码行数:31,代码来源:JenaBasedSadlModelProcessor.java
示例10: renameOntology
import com.hp.hpl.jena.ontology.Ontology; //导入依赖的package包/类
/**
* Rename the ontology, just in case it does not have the same URI as its content...
* This happens
* oldURI should be useless
*/
public void renameOntology( OntModel model, String oldURI, String newURI ) {
Ontology onto = model.getOntology( oldURI );
if ( onto == null ) { // Ugly but efficient
for ( Ontology o : model.listOntologies().toList() ) {
onto = o; break;
}
}
if ( onto == null ) {
model.createOntology( newURI );
} else {
ResourceUtils.renameResource( onto, newURI );
}
}
开发者ID:dozed,项目名称:align-api-project,代码行数:19,代码来源:BasicAlterator.java
示例11: loadImportedModel
import com.hp.hpl.jena.ontology.Ontology; //导入依赖的package包/类
@Override
public List<ImportMapping> loadImportedModel(Ontology importingOntology, OntModel importingModel,
String publicImportUri, String altImportUrl) throws ConfigurationException {
// if not given the publicImportUri, then we must have the altImportUrl so find the publicImportUri in mapping
if (publicImportUri == null) {
if (altImportUrl == null) {
throw new ConfigurationException("Must have either a public URI or an actual URL to import a model.");
}
publicImportUri = getPublicUriFromActualUrl(altImportUrl);
}
if (importingOntology == null) {
throw new ConfigurationException("Importing ontology is null!");
}
// if not given altImportUrl, then we must have the publicImportUri so find the altImportUrl in mapping
if (altImportUrl == null) {
altImportUrl = getAltUrlFromPublicUri(publicImportUri);
}
String importingOntologyUri = importingOntology.getURI();
if (importingOntologyUri == null) {
throw new ConfigurationException("Importing ontology '" + importingOntology.toString() + "' does not have an ontology declaration.");
}
if (!importingOntologyUri.equals(publicImportUri)) { // don't import to self
// Now load import model (with setCachedModels true so it loads any indirect imports)
// and add all import OntModels to importing mappings
Resource importedOntology = importingModel.createResource(publicImportUri);
importingOntology.addImport(importedOntology);
}
// this.getJenaDocumentMgr().setCacheModels(true);
this.getJenaDocumentMgr().setProcessImports(true);
ReadFailureHandler rfh = this.getJenaDocumentMgr().getReadFailureHandler();
if (rfh instanceof SadlReadFailureHandler) {
((SadlReadFailureHandler)rfh).setSadlConfigMgr(this);
}
getModelGetter().configureToModel(importingModel);
importingModel.loadImports();
if (readError != null) {
String err = readError;
readError = null;
if (importingModel.hasLoadedImport(publicImportUri)) {
// this must be removed or it will prevent correct loading from another project
importingModel.removeLoadedImport(publicImportUri);
}
this.getJenaDocumentMgr().setProcessImports(false);
throw new ConfigurationException(err);
}
this.getJenaDocumentMgr().setProcessImports(false);
List<ImportMapping> map = new ArrayList<ImportMapping>();
Iterator<String> itr = importingModel.listImportedOntologyURIs(true).iterator();
while (itr.hasNext()) {
String impUri = itr.next();
if (impUri.equals(importingOntology.getURI())) {
// don't count ourselves as an import
importingModel.setNsPrefix("", ConfigurationManager.addHashToNonTerminatedNamespace(impUri));
continue;
}
String prefix = importingModel.getNsURIPrefix(ConfigurationManager.addHashToNonTerminatedNamespace(impUri));
if (prefix == null) {
prefix = getGlobalPrefix(impUri);
if (prefix != null) {
importingModel.setNsPrefix(prefix, ConfigurationManager.addHashToNonTerminatedNamespace(impUri));
}
}
OntModel impModel = importingModel.getImportedModel(impUri);
String actImpUrl = getAltUrlFromPublicUri(impUri);
logger.debug("processing importingModel, url = "+actImpUrl);
ImportMapping im = new ImportMapping(impUri, actImpUrl, null);
im.setModel(impModel);
im.setPrefix(prefix);
map.add(im);
}
this.getJenaDocumentMgr().setProcessImports(false);
// this.getJenaDocumentMgr().setCacheModels(false);
return map;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:79,代码来源:ConfigurationManager.java
示例12: getOntologies
import com.hp.hpl.jena.ontology.Ontology; //导入依赖的package包/类
public List<Ontology> getOntologies() {
return ontologies;
}
开发者ID:crapo,项目名称:sadlos2,代码行数:4,代码来源:OwlToSadl.java
示例13: MeasurementTypeGenerator
import com.hp.hpl.jena.ontology.Ontology; //导入依赖的package包/类
public MeasurementTypeGenerator() {
// prep the namespace prefixes
namespaces.put("ecso", ecsoPrefix);
namespaces.put("taxa", taxaPrefix);
namespaces.put("envo", envoPrefix);
namespaces.put("pato", patoPrefix);
namespaces.put("uo", uoPrefix);
namespaces.put("oboe", AnnotationGenerator.oboe);
namespaces.put("oboe-core", AnnotationGenerator.oboe_core);
namespaces.put("oboe-characteristics", AnnotationGenerator.oboe_characteristics);
// retrieve the ECSO ontology
ecsoModel = ModelFactory.createOntologyModel();
ecsoModel.read(ecso);
AnnotationGenerator.initializeCache();
// construct the ontology model for additions
m = ModelFactory.createOntologyModel();
Ontology ont = m.createOntology(ecso);
ont.addImport(m.createResource(AnnotationGenerator.oboe));
m.addSubModel(OntDocumentManager.getInstance().getModel(AnnotationGenerator.oboe));
// properties
rdfsLabel = ecsoModel.getProperty(AnnotationGenerator.rdfs + "label");
measuresCharacteristic = ecsoModel.getObjectProperty(AnnotationGenerator.oboe_core + "measuresCharacteristic");
measuresEntity = ecsoModel.getObjectProperty(AnnotationGenerator.oboe_core + "measuresEntity");
// classes
entityClass = ecsoModel.getOntClass(AnnotationGenerator.oboe_core + "Entity");
characteristicClass = ecsoModel.getOntClass(AnnotationGenerator.oboe_core + "Characteristic");
measurementTypeClass = ecsoModel.getOntClass(AnnotationGenerator.oboe_core + "MeasurementType");
// where do we begin with our counting?
classId = Settings.getConfiguration().getInt("annotator.ontology.classId");
// prep ALL concepts for quick look up
ExtendedIterator<OntClass> classIter = ecsoModel.listNamedClasses();
while (classIter.hasNext()) {
OntClass cls = classIter.next();
String label = cls.getLabel(null);
if (label == null) {
label = cls.getLocalName();
}
log.trace("Initializing class label: " + label);
allConcepts.put(label, cls);
}
}
开发者ID:DataONEorg,项目名称:annotator,代码行数:54,代码来源:MeasurementTypeGenerator.java
示例14: run
import com.hp.hpl.jena.ontology.Ontology; //导入依赖的package包/类
public void run(Configuration configuration) {
try {
this.connector.connect();
final NextPageResolver resolver = configuration.getNextPageResolver();
int i = 0;
while (resolver.hasNext()) {
final String currentId = configuration.getId() + "-" + String.format("%04d", i);
final String ontoId = configuration.getBaseOntoPrefix() + currentId;
final String input = resolver.next();
logger.info("Page " + i+" : "+input);
final OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
final Ontology ont = model.createOntology(ontoId);
for (final String imp : configuration.getSchemas()) {
ont.addImport(ModelFactory.createOntologyModel().createOntology(imp));
}
Individual org = model.createIndividual(configuration.getPublisher(), model.createClass(Vocabulary.w3cOrganization));
model.add(ont, DC.source, input);
model.add(ont, DC.publisher, org);
model.add(ont, DC.date, model.createLiteral(new Date().toString()));
logger.debug(" parsing definitions ...");
for (InitialDefinition entry : configuration.getInitialDefinitions()) {
new Crowler(model, configuration, input, input, entry).crawl();
}
logger.debug(" opening persist model...");
final Model persistModel = connector.getModel(ontoId);
logger.debug(" saving ...");
persistModel.add(model);
logger.debug(" closing...");
connector.closeModel(persistModel);
logger.debug(" done.");
i++;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
logger.info("Disconnecting backend.");
connector.disconnect();
}
}
开发者ID:psiotwo,项目名称:crowler,代码行数:48,代码来源:FullCrawler.java
示例15: loadImportedModel
import com.hp.hpl.jena.ontology.Ontology; //导入依赖的package包/类
/**
* Method to load an imported model, along with any indirect imports, and return the
* loaded models and information about each model as a list of ImportMappings. The
* models are only stored in the Jena model cache long enough to retrieve them for
* inclusion in the list. Jena caching is then turned off as it seems to create memory problems.
*
* Normally either the public URI or the actual URL of the imported model will be known.
*
* @param importingModel - the OntModel that is importing another model
* @param publicImportUri - the public URI of the other (imported) model
* @param altImportUrl - the actual URL of the other (imported) model
* @return
* @throws ConfigurationException
*/
public abstract List<ImportMapping> loadImportedModel(
Ontology importingOntology, OntModel importingModel,
String publicImportUri, String altImportUrl)
throws ConfigurationException;
开发者ID:crapo,项目名称:sadlos2,代码行数:19,代码来源:IConfigurationManager.java
注:本文中的com.hp.hpl.jena.ontology.Ontology类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论