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


Java OWLOntology.getOWLOntologyManager方法代码示例

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


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

示例1: addBioEntity

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
private void addBioEntity(OWLClass pr, OWLOntology lego, Bioentity bioentity) {
	Set<OWLDeclarationAxiom> declarationAxioms = lego.getDeclarationAxioms(pr);
	if (declarationAxioms == null || declarationAxioms.isEmpty()) {
		// add class declaration and add label
		OWLOntologyManager m = lego.getOWLOntologyManager();
		OWLDataFactory f = m.getOWLDataFactory();
		
		Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
		axioms.add(f.getOWLDeclarationAxiom(pr));
		
		String label = bioentity.getSymbol()+" - "+bioentity.getFullName();
		
		axioms.add(f.getOWLAnnotationAssertionAxiom(f.getRDFSLabel(), pr.getIRI(), f.getOWLLiteral(label)));
		
		m.addAxioms(lego, axioms);
	}
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:18,代码来源:GafToLegoTranslator.java

示例2: minimizedTranslate

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
/**
 * Translate the given {@link GafDocument} into an OWL representation of the LEGO model.
 * Additionally minimize the lego model and imports into one ontology module.
 * 
 * @param gaf
 * @return minimized lego ontology
 */
public OWLOntology minimizedTranslate(GafDocument gaf) {
	OWLOntology all = translate(gaf);
	final OWLOntologyManager m = all.getOWLOntologyManager();
	
	SyntacticLocalityModuleExtractor sme = new SyntacticLocalityModuleExtractor(m, all, ModuleType.BOT);
	Set<OWLEntity> sig = new HashSet<OWLEntity>(all.getIndividualsInSignature());
	Set<OWLAxiom> moduleAxioms = sme.extract(sig);
	
	try {
		OWLOntology module = m.createOntology(IRI.generateDocumentIRI());
		m.addAxioms(module, moduleAxioms);
		return module;
	} catch (OWLException e) {
		throw new RuntimeException("Could not create minimized lego model.", e);
	}
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:24,代码来源:GafToLegoTranslator.java

示例3: saveModel

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
/**
 * Save a model to the database.
 * 
 * @param m
 * @param annotations
 * @param metadata
 *
 * @throws OWLOntologyStorageException
 * @throws OWLOntologyCreationException
 * @throws IOException
 * @throws RepositoryException 
 * @throws UnknownIdentifierException 
 */
public void saveModel(ModelContainer m,
		Set<OWLAnnotation> annotations, METADATA metadata)
				throws OWLOntologyStorageException, OWLOntologyCreationException,
				IOException, RepositoryException, UnknownIdentifierException {
	IRI modelId = m.getModelId();
	final OWLOntology ont = m.getAboxOntology();
	final OWLOntologyManager manager = ont.getOWLOntologyManager();
	List<OWLOntologyChange> changes = preSaveFileHandler(ont);
	synchronized(ont) {
		try {
			this.writeModelToDatabase(ont, modelId);
			// reset modified flag for abox after successful save
			m.setAboxModified(false);
		} finally {
			if (changes != null) {
				List<OWLOntologyChange> invertedChanges = ReverseChangeGenerator
						.invertChanges(changes);
				if (invertedChanges != null && !invertedChanges.isEmpty()) {
					manager.applyChanges(invertedChanges);
				}
			}
		}
	}
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:38,代码来源:BlazegraphMolecularModelManager.java

示例4: removeRedundantSubClassAxioms

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
/**
 * Remove the redundant and marked as inferred super class assertions for
 * each class in the ontology signature. Uses the reasoner to infer the
 * direct super classes.
 * 
 * @param ontology
 * @param reasoner
 * @return map of class to set of redundant axioms
 */
public static Map<OWLClass, Set<RedundantAxiom>> removeRedundantSubClassAxioms(OWLOntology ontology, OWLReasoner reasoner) {
	Iterable<OWLClass> classes = ontology.getClassesInSignature();
	Map<OWLClass, Set<RedundantAxiom>> axioms = findRedundantSubClassAxioms(classes, ontology, reasoner);
	if (!axioms.isEmpty()) {
		Set<OWLSubClassOfAxiom> allAxioms = new THashSet<OWLSubClassOfAxiom>();
		for(OWLClass cls : axioms.keySet()) {
			for(RedundantAxiom redundantAxiom : axioms.get(cls)) {
				allAxioms.add(redundantAxiom.getAxiom());
			}
		}
		OWLOntologyManager manager = ontology.getOWLOntologyManager();
		manager.removeAxioms(ontology, allAxioms);
		LOG.info("Removed "+axioms.size()+" redundant axioms.");
	}
	return axioms;
	
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:27,代码来源:RedundantInferences.java

示例5: synonym

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
/**
 * Add an synonym annotation, plus an annotation on that annotation
 * that specified the type of synonym. The second annotation has the
 * property oio:hasSynonymType.
 *
 * @param ontology the current ontology
 * @param subject the subject of the annotation
 * @param type the IRI of the type of synonym
 * @param property the IRI of the annotation property.
 * @param value the literal value of the synonym
 * @return the synonym annotation axiom
 */
protected static OWLAnnotationAssertionAxiom synonym(
		OWLOntology ontology, OWLEntity subject, 
		OWLAnnotationValue type,
		OWLAnnotationProperty property, 
		OWLAnnotationValue value) {
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	OWLDataFactory dataFactory = manager.getOWLDataFactory();
	OWLAnnotationProperty hasSynonymType =
		dataFactory.getOWLAnnotationProperty(
			format.getIRI("oio:hasSynonymType"));
	OWLAnnotation annotation = 
		dataFactory.getOWLAnnotation(hasSynonymType, type);
	Set<OWLAnnotation> annotations = new HashSet<OWLAnnotation>();
	annotations.add(annotation);
	OWLAnnotationAssertionAxiom axiom =
		dataFactory.getOWLAnnotationAssertionAxiom(
			property, subject.getIRI(), value,
			annotations);
	manager.addAxiom(ontology, axiom);
	return axiom;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:34,代码来源:OWLConverter.java

示例6: setOntology

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
@Override
public void setOntology(OWLOntology o) {
    this.ontology = o;
    this.manager = o.getOWLOntologyManager();
    Configuration conf = new Configuration();
    this.reasoner = new Reasoner(conf, ontology);
}
 
开发者ID:IBCNServices,项目名称:OBEP,代码行数:8,代码来源:AbstracterImpl.java

示例7: AlternativeUelStarter

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
public AlternativeUelStarter(OWLOntology ontology) {
	if (ontology == null) {
		throw new IllegalArgumentException("Null argument.");
	}
	this.ontologyManager = ontology.getOWLOntologyManager();
	this.ontologies = new HashSet<>();
	this.ontologies.add(ontology);
}
 
开发者ID:julianmendez,项目名称:uel,代码行数:9,代码来源:AlternativeUelStarter.java

示例8: getDcSourceProperty

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
private OWLAnnotationProperty getDcSourceProperty(OWLOntology lego, OWLDataFactory f) {
	OWLAnnotationProperty p = f.getOWLAnnotationProperty(DC_SOURCE);
	Set<OWLDeclarationAxiom> declarationAxioms = lego.getDeclarationAxioms(p);
	if (declarationAxioms == null || declarationAxioms.isEmpty()) {
		OWLOntologyManager m = lego.getOWLOntologyManager();
		m.addAxiom(lego, f.getOWLDeclarationAxiom(p));
	}
	return p;
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:10,代码来源:GafToLegoTranslator.java

示例9: appendXrefAnnotations

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
/**
 * Append xref annotations onto an existing axiom
 * 
 * @param axiom
 * @param xrefs
 * @param ontology
 * @return
 */
public static OWLAxiom appendXrefAnnotations(OWLAxiom axiom, Set<String> xrefs, OWLOntology ontology) {
    // filter existing
    Set<OWLAnnotation> newAnnotations = new HashSet<OWLAnnotation>(axiom.getAnnotations());
       final OWLOntologyManager manager = ontology.getOWLOntologyManager();
    final OWLDataFactory factory = manager.getOWLDataFactory();

    for (String x : xrefs) {
        OWLAnnotationProperty p = factory.getOWLAnnotationProperty(IRI.create("http://www.geneontology.org/formats/oboInOwl#hasDbXref"));
        OWLLiteral v = factory.getOWLLiteral(x);
        newAnnotations.add(factory.getOWLAnnotation(p, v));
    }
    final OWLAxiom newAxiom = changeAxiomAnnotations(axiom, newAnnotations, ontology);
    return newAxiom;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:23,代码来源:AxiomAnnotationTools.java

示例10: exportModel

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
/**
 * Export the ABox, will try to set the ontologyID to the given modelId (to
 * ensure import assumptions are met)
 * 
 * @param model
 * @param ontologyFormat
 * @return modelContent
 * @throws OWLOntologyStorageException
 */
public String exportModel(ModelContainer model, OWLDocumentFormat ontologyFormat) throws OWLOntologyStorageException {
	final OWLOntology aBox = model.getAboxOntology();
	final OWLOntologyManager manager = aBox.getOWLOntologyManager();
	
	// make sure the exported ontology has an ontologyId and that it maps to the modelId
	final IRI expectedABoxIRI = model.getModelId();
	Optional<IRI> currentABoxIRI = aBox.getOntologyID().getOntologyIRI();
	if (currentABoxIRI.isPresent() == false) {
		manager.applyChange(new SetOntologyID(aBox, expectedABoxIRI));
	}
	else {
		if (expectedABoxIRI.equals(currentABoxIRI) == false) {
			OWLOntologyID ontologyID = new OWLOntologyID(Optional.of(expectedABoxIRI), Optional.of(expectedABoxIRI));
			manager.applyChange(new SetOntologyID(aBox, ontologyID));
		}
	}

	// write the model into a buffer
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	if (ontologyFormat != null) {
		manager.saveOntology(aBox, ontologyFormat, outputStream);
	}
	else {
		manager.saveOntology(aBox, outputStream);
	}
	
	// extract the string from the buffer
	String modelString = outputStream.toString();
	return modelString;
}
 
开发者ID:geneontology,项目名称:minerva,代码行数:40,代码来源:CoreMolecularModelManager.java

示例11: ElkReasoner

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
ElkReasoner(OWLOntology ontology, boolean isBufferingMode,
		ElkReasonerConfiguration elkConfig,
		final Reasoner internalReasoner) {
	this.owlOntology_ = ontology;
	this.owlOntologymanager_ = ontology.getOWLOntologyManager();
	this.mainProgressMonitor_ = elkConfig.getProgressMonitor() == null
			? new DummyProgressMonitor()
			: new ElkReasonerProgressMonitor(
					elkConfig.getProgressMonitor());
	this.secondaryProgressMonitor_ = new DummyProgressMonitor();
	this.isBufferingMode_ = isBufferingMode;
	this.ontologyChangeListener_ = new OntologyChangeListener();
	this.owlOntologymanager_
			.addOntologyChangeListener(ontologyChangeListener_);
	this.ontologyChangeProgressListener_ = new OntologyChangeProgressListener();
	this.owlOntologymanager_.addOntologyChangeProgessListener(
			ontologyChangeProgressListener_);
	this.objectFactory_ = internalReasoner.getElkFactory();
	this.owlConverter_ = OwlConverter.getInstance();
	this.elkConverter_ = ElkConverter.getInstance();

	this.config_ = elkConfig.getElkConfiguration();
	this.isAllowFreshEntities = elkConfig
			.getFreshEntityPolicy() == FreshEntityPolicy.ALLOW;

	initReasoner(internalReasoner);
	this.bufferedChangesLoader_ = new OwlChangesLoaderFactory(
			this.mainProgressMonitor_);
	if (!isBufferingMode_) {
		// register the change loader only in non-buffering mode;
		// in buffering mode the loader is registered only when
		// changes are flushed
		reasoner_.registerAxiomLoader(bufferedChangesLoader_);
	}
	this.ontologyReloadRequired_ = false;
}
 
开发者ID:liveontologies,项目名称:elk-reasoner,代码行数:37,代码来源:ElkReasoner.java

示例12: assertSubClass

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
/**
 * Convenience method for asserting a subClass relation between
 * a parent and child class in an ontology.
 *
 * @param ontology the current ontology
 * @param child the child class
 * @param parent the parent class
 * @return the axiom
 */
protected static OWLSubClassOfAxiom assertSubClass(
		OWLOntology ontology, OWLClass child, OWLClass parent) {
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	OWLDataFactory dataFactory = manager.getOWLDataFactory();
	OWLSubClassOfAxiom axiom = 
		dataFactory.getOWLSubClassOfAxiom(child, parent);
	ontology.getOWLOntologyManager().addAxiom(ontology, axiom);
	return axiom;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:19,代码来源:OWLConverter.java

示例13: OldSimpleOwlSim

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
public OldSimpleOwlSim(OWLOntology sourceOntology) {
	super();
	this.sourceOntology = sourceOntology;
	this.owlOntologyManager = sourceOntology.getOWLOntologyManager();
	this.owlDataFactory = owlOntologyManager.getOWLDataFactory();
	this.sourceOntology = sourceOntology;
	init();
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:9,代码来源:OldSimpleOwlSim.java

示例14: annotate

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
/**
 * Convenience method for adding an annotation assertion to the
 * ontology itself, taking a CURIE for the property and an Boolean literal.
 *
 * @param ontology the current ontology
 * @param propertyCURIE will be expanded to the full annotation
 *	property IRI
 * @param value the literal value of the annotation
 * @return the annotation axiom
 */
protected static OWLAnnotation annotate(OWLOntology ontology,
		String propertyCURIE, IRI value) {
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	OWLDataFactory dataFactory = manager.getOWLDataFactory();
	IRI iri = format.getIRI(propertyCURIE);
	OWLAnnotationProperty property =
		dataFactory.getOWLAnnotationProperty(iri);
	OWLAnnotation annotation = dataFactory.getOWLAnnotation(
			property, value);
	manager.applyChange(
		new AddOntologyAnnotation(ontology, annotation));
	return annotation;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:24,代码来源:OWLConverter.java

示例15: PropertyViewOntologyBuilder

import org.semanticweb.owlapi.model.OWLOntology; //导入方法依赖的package包/类
/**
 * @param sourceOntology
 * @param elementsOntology
 * @param viewProperty
 */
public PropertyViewOntologyBuilder(OWLOntology sourceOntology,
		OWLOntology elementsOntology, OWLObjectProperty viewProperty) {
	super();
	this.owlOntologyManager = sourceOntology.getOWLOntologyManager();
	this.owlDataFactory = owlOntologyManager.getOWLDataFactory();
	this.sourceOntology = sourceOntology;
	this.elementsOntology = elementsOntology;
	this.viewProperty = viewProperty;
	init();
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:16,代码来源:PropertyViewOntologyBuilder.java


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