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


Java OWLOntologyManager.applyChanges方法代碼示例

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


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

示例1: saveModel

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的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

示例2: addAutoGeneratedClassNames

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
private void addAutoGeneratedClassNames(OWLOntologyManager manager,
										OWLOntology ontology,
										Map<String, OWLClassExpression> nameMap) {
	
	OWLDataFactory factory = manager.getOWLDataFactory();
	List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
	
	for (Map.Entry<String, OWLClassExpression> entry : nameMap.entrySet()) {
		
		OWLClass subClass = factory.getOWLClass( IRI.create(entry.getKey()) );
		OWLAxiom declAxiom = factory.getOWLEquivalentClassesAxiom( subClass, entry.getValue() );
		
		changes.addAll( manager.addAxiom( ontology, declAxiom ) );
	}
	
	manager.applyChanges( changes );
}
 
開發者ID:klinovp,項目名稱:pronto,代碼行數:18,代碼來源:KBStandaloneLoader.java

示例3: getModuleFromAxioms

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
 * Necessary toi construct a module for an arbitriary set of axioms
 * @param moduleAxioms
 * @param moduleUri
 * @return
 */
public OWLOntology getModuleFromAxioms(Set<OWLAxiom> moduleAxioms, IRI moduleIri) {
	
	OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
	
	OWLOntology module=null;
	
	try {
		module = ontologyManager.createOntology(moduleIri);
		List<OWLOntologyChange> ontoChanges = new ArrayList<OWLOntologyChange>();
		for(OWLAxiom axiom : moduleAxioms) {
			ontoChanges.add(new AddAxiom(module, axiom));
		}
		ontologyManager.applyChanges(ontoChanges);
	}
	
	catch(Exception e) {
		System.out.println("Error creating module ontology from extende set of axioms.");
		
	}

	//System.out.println("Time create OWLOntology for module (s): " + (double)((double)fin-(double)init)/1000.0);
	
	return module;
}
 
開發者ID:ernestojimenezruiz,項目名稱:logmap-matcher,代碼行數:31,代碼來源:ModuleExtractorManager.java

示例4: proofCompletenessTest

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
public static <I extends Inference<?>> void proofCompletenessTest(
		final OWLProver prover, final OWLAxiom entailment,
		final Object conclusion, final Proof<? extends I> proof,
		final InferenceJustifier<? super I, ? extends Set<? extends OWLAxiom>> justifier,
		final boolean mustNotBeATautology) {

	final OWLOntology ontology = prover.getRootOntology();
	final OWLOntologyManager manager = ontology.getOWLOntologyManager();

	// compute repairs

	final Set<Set<? extends OWLAxiom>> repairs = new HashSet<Set<? extends OWLAxiom>>();
	MinimalSubsetEnumerators.enumerateRepairs(conclusion, proof, justifier,
			InterruptMonitor.DUMMY,
			new MinimalSubsetCollector<OWLAxiom>(repairs));

	if (mustNotBeATautology) {
		assertFalse("Entailment is a tautology; there are no repairs!",
				repairs.isEmpty());
	}

	for (final Set<? extends OWLAxiom> repair : repairs) {

		final List<OWLOntologyChange> deletions = new ArrayList<OWLOntologyChange>();
		final List<OWLOntologyChange> additions = new ArrayList<OWLOntologyChange>();
		for (final OWLAxiom axiom : repair) {
			deletions.add(new RemoveAxiom(ontology, axiom));
			additions.add(new AddAxiom(ontology, axiom));
		}

		manager.applyChanges(deletions);

		final boolean conclusionDerived = prover.isEntailed(entailment);

		manager.applyChanges(additions);

		assertFalse("Not all proofs were found!\n" + "Conclusion: "
				+ conclusion + "\n" + "Repair: " + repair,
				conclusionDerived);
	}

}
 
開發者ID:liveontologies,項目名稱:elk-reasoner,代碼行數:43,代碼來源:ProofTestUtils.java

示例5: proofsUnderOntologyUpdate

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Test
public void proofsUnderOntologyUpdate() throws Exception {
	// loading and classifying via the OWL API
	OWLOntology ontology = loadOntology(
			ProofTest.class.getClassLoader().getResourceAsStream(
					"ontologies/PropertyCompositionsWithHierarchy.owl"));
	final OWLProver prover = OWLAPITestUtils.createProver(ontology);

	prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	OWLClass sub = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass sup = factory.getOWLClass(IRI.create("http://example.org/G"));

	// printInferences(reasoner, sub, sup);
	// OWLExpression root =
	// reasoner.getDerivedExpression(factory.getOWLSubClassOfAxiom(sub,
	// sup));
	// System.err.println(OWLProofUtils.printProofTree(root));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(sub, sup));

	// now convert C <= R3 some D to C < S3 some D
	OWLClass c = factory.getOWLClass(IRI.create("http://example.org/C"));
	OWLClass d = factory.getOWLClass(IRI.create("http://example.org/D"));
	OWLObjectProperty r3 = factory
			.getOWLObjectProperty(IRI.create("http://example.org/R3"));
	OWLObjectProperty s3 = factory
			.getOWLObjectProperty(IRI.create("http://example.org/S3"));
	OWLAxiom oldAx = factory.getOWLSubClassOfAxiom(c,
			factory.getOWLObjectSomeValuesFrom(r3, d));
	OWLAxiom newAx = factory.getOWLSubClassOfAxiom(c,
			factory.getOWLObjectSomeValuesFrom(s3, d));

	OWLOntologyManager manager = ontology.getOWLOntologyManager();

	manager.applyChanges(Arrays.asList(new RemoveAxiom(ontology, oldAx),
			new AddAxiom(ontology, newAx)));

	prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	// printInferences(reasoner, sub, sup);
	// root =
	// reasoner.getDerivedExpression(factory.getOWLSubClassOfAxiom(sub,
	// sup));
	// System.err.println(OWLProofUtils.printProofTree(root));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(sub, sup));
}
 
開發者ID:liveontologies,項目名稱:elk-reasoner,代碼行數:49,代碼來源:ProofTest.java

示例6: createSubSet

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
public void createSubSet(OWLGraphWrapper targetGraph, 
		Set<OWLClass> subset, Set<OWLOntology> toMerge, boolean isExcludeClosure,
		boolean isRemoveDangling) throws OWLOntologyCreationException  {

	OWLOntology targetOntology = targetGraph.getSourceOntology();

	// import axioms set
	Set<OWLAxiom> importAxioms = new HashSet<OWLAxiom>();
	for (OWLOntology mergeOntology : toMerge) {
		for (OWLClass cls : subset) {
			importAxioms.addAll(mergeOntology.getAxioms(cls, Imports.EXCLUDED));
		}
	}

	// remove merge imports
	OWLOntologyManager targetManager = targetOntology.getOWLOntologyManager();
	List<OWLOntologyChange> removeImports = new ArrayList<OWLOntologyChange>();
	for(OWLOntology m : toMerge) {
		removeImports.add(new RemoveImport(targetOntology, new OWLImportsDeclarationImpl(m.getOntologyID().getOntologyIRI().get())));
	}
	targetManager.applyChanges(removeImports);

	// add axiom set to target ontology.
	targetManager.addAxioms(targetOntology, importAxioms);

	LOG.info("Start Mooncat for subset.");
	Mooncat mooncat = new Mooncat(targetGraph);
	for (OWLOntology ont : toMerge) {
		mooncat.addReferencedOntology(ont);
	}

	if (!isExcludeClosure) {
		// create Closure
		Set<OWLAxiom> axioms = mooncat.getClosureAxiomsOfExternalReferencedEntities();
		mooncat.addSubAnnotationProperties(axioms);

		// add missing axioms
		targetManager.addAxioms(targetOntology, axioms);
		LOG.info("Added "+axioms.size()+" axioms to the query ontology");
	}
	
	if (isRemoveDangling) {
		mooncat.removeDanglingAxioms();
	}

	return;
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:48,代碼來源:QuerySubsetGenerator.java

示例7: cleanupSupportOntologies

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
private static void  cleanupSupportOntologies(OWLGraphWrapper graph, List<OWLOntologyChange> remove)
{
	OWLOntology ontology = graph.getSourceOntology();
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	manager.applyChanges(remove);
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:7,代碼來源:AssertInferenceTool.java


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