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


Java OWLOntologyManager.getOWLDataFactory方法代碼示例

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


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

示例1: testTinyOntology8

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
 * @throws OWLOntologyCreationException
 *             if something goes wrong with the ontology creation
 */
@Test
public void testTinyOntology8() throws OWLOntologyCreationException {
	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
	OWLDataFactory factory = manager.getOWLDataFactory();
	Set<OWLAxiom> axiomSet = new HashSet<>();
	OWLClass a = createNewClass(factory, "A");
	OWLClass b = createNewClass(factory, "B");
	OWLClass ab = createNewClass(factory, "AB");

	Set<OWLClass> aAndBSet = new HashSet<>();
	aAndBSet.add(a);
	aAndBSet.add(b);
	OWLClassExpression aAndB = factory.getOWLObjectIntersectionOf(aAndBSet);
	axiomSet.add(factory.getOWLEquivalentClassesAxiom(ab, aAndB));

	OWLOntology ontology = manager.createOntology(axiomSet);
	JcelReasonerFactory reasonerFactory = new JcelReasonerFactory();
	OWLReasoner reasoner = reasonerFactory.createReasoner(ontology);
	Set<OWLClass> expectedSet = new HashSet<>();
	expectedSet.add(ab);
	Node<OWLClass> expected = new OWLClassNode(expectedSet);
	Assert.assertEquals(expected, reasoner.getEquivalentClasses(ab));
	Assert.assertEquals(expected, reasoner.getEquivalentClasses(aAndB));
}
 
開發者ID:julianmendez,項目名稱:jcel,代碼行數:29,代碼來源:TinyOntologyTest.java

示例2: handleSupportOntologies

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
private static List<OWLOntologyChange> handleSupportOntologies(OWLGraphWrapper graph)
{
	OWLOntology ontology = graph.getSourceOntology();
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	OWLDataFactory factory = manager.getOWLDataFactory();
	
	List<OWLOntologyChange> removeImportChanges = new ArrayList<OWLOntologyChange>();
	Set<OWLOntology> supportOntologySet = graph.getSupportOntologySet();
	for (OWLOntology support : supportOntologySet) {
		Optional<IRI> supportIRI = support.getOntologyID().getOntologyIRI();
		if(supportIRI.isPresent()) {
			IRI ontologyIRI = supportIRI.get();
			OWLImportsDeclaration importDeclaration = factory.getOWLImportsDeclaration(ontologyIRI);
			ChangeApplied status = manager.applyChange(new AddImport(ontology, importDeclaration));
			if (ChangeApplied.SUCCESSFULLY == status) {
				// the change was successful, create remove import for later
				removeImportChanges.add(new RemoveImport(ontology, importDeclaration));
			}
		}
	}
	return removeImportChanges;
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:23,代碼來源:AssertInferenceTool.java

示例3: testDataPropertyMetadata

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Test
public void testDataPropertyMetadata() throws Exception {
	OWLOntologyManager m = OWLManager.createOWLOntologyManager();
	OWLOntology ontology = m.createOntology(IRI.generateDocumentIRI());
	{
		// create a test ontology with one data property
		OWLDataFactory f = m.getOWLDataFactory();
		IRI propIRI = IRI.generateDocumentIRI();
		OWLDataProperty prop = f.getOWLDataProperty(propIRI);
		m.addAxiom(ontology, f.getOWLDeclarationAxiom(prop));
		m.addAxiom(ontology, f.getOWLAnnotationAssertionAxiom(propIRI, f.getOWLAnnotation(f.getRDFSLabel(), f.getOWLLiteral("fake-data-property"))));
	}
	OWLGraphWrapper graph = new OWLGraphWrapper(ontology);
	MolecularModelManager<?> mmm = createM3(graph);
	Pair<List<JsonRelationInfo>,List<JsonRelationInfo>> pair = MolecularModelJsonRenderer.renderProperties(mmm, null, curieHandler);
	List<JsonRelationInfo> dataProperties = pair.getRight();
	assertEquals(1, dataProperties.size());
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:19,代碼來源:DataPropertyTest.java

示例4: 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

示例5: addElementLabels

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
public static void addElementLabels(OWLOntology ont, File file) throws IOException {
	OWLOntologyManager m = OWLManager.createOWLOntologyManager();
	OWLDataFactory df = m.getOWLDataFactory();
	List<String> lines = FileUtils.readLines(file);
	for (String line : lines) {
		if (line.startsWith("#"))
			continue;
		String[] colVals = line.split("\t");
		if (colVals.length != 2) {
			throw new IOException("Incorrect number of value: "+line);
		}
		IRI i = getIRIById(colVals[0]);
		OWLAnnotation ann = df.getOWLAnnotation(df.getRDFSLabel(), df.getOWLLiteral(colVals[1])); 
		m.addAxiom(ont, df.getOWLAnnotationAssertionAxiom(i, ann));
	}
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:17,代碼來源:OwlSimUtil.java

示例6: setUp

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
    graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(new File(TEST_GRAPH_DB_PATH));
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLOntology ontology = manager.loadOntologyFromOntologyDocument(file.getFile());
    OWLDataFactory factory = manager.getOWLDataFactory();
    loader = new Owl2Neo4jLoader(graphDb, ontology, factory);
}
 
開發者ID:ISA-tools,項目名稱:FAIRsharing-Owl2Neo,代碼行數:9,代碼來源:Owl2Neo4jLoaderTest.java

示例7: StatisticalFunctionalityDetector

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
public StatisticalFunctionalityDetector(File ontologyFile, double threshold) {
	try {
		OWLOntologyManager man = OWLManager.createOWLOntologyManager();
		ontology = man.loadOntologyFromOntologyDocument(ontologyFile);
		dataFactory = man.getOWLDataFactory();
	} catch (OWLOntologyCreationException e) {
		e.printStackTrace();
	}
	this.threshold = threshold;
}
 
開發者ID:dice-group,項目名稱:BENGAL,代碼行數:11,代碼來源:StatisticalFunctionalityDetector.java

示例8: testDataProperyRenderer

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Test
public void testDataProperyRenderer() throws Exception {
	OWLOntologyManager m = OWLManager.createOWLOntologyManager();
	OWLOntology ontology = m.createOntology(IRI.generateDocumentIRI());
	final IRI clsIRI = IRI.generateDocumentIRI();
	final IRI propIRI = IRI.generateDocumentIRI();
	
	// create a test ontology with one data property and one class
	OWLDataFactory f = m.getOWLDataFactory();
	OWLDataProperty prop = f.getOWLDataProperty(propIRI);
	m.addAxiom(ontology, f.getOWLDeclarationAxiom(prop));
	m.addAxiom(ontology, f.getOWLAnnotationAssertionAxiom(propIRI, f.getOWLAnnotation(f.getRDFSLabel(), f.getOWLLiteral("fake-data-property"))));

	OWLClass cls = f.getOWLClass(clsIRI);
	m.addAxiom(ontology, f.getOWLDeclarationAxiom(cls));
	m.addAxiom(ontology, f.getOWLAnnotationAssertionAxiom(clsIRI, f.getOWLAnnotation(f.getRDFSLabel(), f.getOWLLiteral("fake-cls"))));
	
	// graph and m3
	OWLGraphWrapper graph = new OWLGraphWrapper(ontology);
	final UndoMetadata metadata = new UndoMetadata("foo-user");
	UndoAwareMolecularModelManager m3 = createM3(graph);
	
	final ModelContainer model = m3.generateBlankModel(metadata);
	final OWLNamedIndividual individual = m3.createIndividual(model, cls, metadata);
	m3.addDataProperty(model, individual, prop, f.getOWLLiteral(10), metadata);
	
	MolecularModelJsonRenderer r = new MolecularModelJsonRenderer(model, null, curieHandler);
	final JsonModel jsonModel = r.renderModel();
	assertEquals(1, jsonModel.individuals.length);
	assertEquals(1, jsonModel.individuals[0].annotations.length);
	{
		JsonAnnotation ann = jsonModel.individuals[0].annotations[0];
		assertEquals(propIRI.toString(), ann.key);
		assertEquals("10", ann.value);
		assertEquals("xsd:integer", ann.valueType);
	}
}
 
開發者ID:geneontology,項目名稱:minerva,代碼行數:38,代碼來源:DataPropertyTest.java

示例9: modifyInferredAxiom

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
private static OWLAxiom modifyInferredAxiom(OWLAxiom axiom, OWLOntology ontology, boolean add) {
	final OWLOntologyManager manager = ontology.getOWLOntologyManager();
	final OWLDataFactory factory = manager.getOWLDataFactory();
	final OWLAxiom newAxiom = updateInferredAxiom(axiom, factory, add);
	
	// update ontology
	manager.removeAxiom(ontology, axiom);
	manager.addAxiom(ontology, newAxiom);
	return newAxiom;
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:11,代碼來源:AxiomAnnotationTools.java

示例10: executeDLQuery

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
 * Execute the DL query on the given ontology graph. Uses the factory to create 
 * the {@link OWLReasoner} for an internal query ontology.
 * 
 * @param dlQuery
 * @param graph
 * @param reasonerFactory
 * @return set of {@link OWLClass} which 
 * @throws OWLParserException
 * @throws OWLOntologyCreationException
 */
public static Set<OWLClass> executeDLQuery(String dlQuery, OWLGraphWrapper graph, 
		OWLReasonerFactory reasonerFactory) throws OWLParserException, OWLOntologyCreationException 
{
	// create parser and parse DL query string
	ManchesterSyntaxTool parser = null;
	
	OWLClassExpression ce;
	try {
		parser = new ManchesterSyntaxTool(graph.getSourceOntology(), graph.getSupportOntologySet());
		ce = parser.parseManchesterExpression(dlQuery);
	} finally {
		// always dispose parser to avoid a memory leak
		if (parser != null) {
			parser.dispose();
		}
	}
	
	// create query ontology
	OWLOntologyManager m = OWLManager.createOWLOntologyManager();
	OWLOntology queryOntology = m.createOntology(IRI.generateDocumentIRI(), graph.getAllOntologies());
	OWLDataFactory f = m.getOWLDataFactory();
	OWLClass qc = f.getOWLClass(IRI.create("http://owltools.org/Q"));
	OWLEquivalentClassesAxiom ax = f.getOWLEquivalentClassesAxiom(ce, qc);
	m.addAxiom(queryOntology, ax);
	
	Set<OWLClass> subset = executeQuery(ce, queryOntology, reasonerFactory);
	if(subset.isEmpty()) {
		LOG.warn("No classes found for query subclass of:"+dlQuery);
	}
	return subset;
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:43,代碼來源:DLQueryTool.java

示例11: appendXrefAnnotations

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

示例12: annotate

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的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, String value) {
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	OWLDataFactory dataFactory = manager.getOWLDataFactory();
	IRI iri = format.getIRI(propertyCURIE);
	OWLAnnotationProperty property =
		dataFactory.getOWLAnnotationProperty(iri);
	OWLLiteral literal = dataFactory.getOWLLiteral(value);
	OWLAnnotation annotation = dataFactory.getOWLAnnotation(
			property, literal);
	manager.applyChange(
		new AddOntologyAnnotation(ontology, annotation));
	return annotation;
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:25,代碼來源:OWLConverter.java

示例13: setInformationContentFromOntology

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
@Override
public void setInformationContentFromOntology(OWLOntology o) {
	OWLOntologyManager mgr = getSourceOntology().getOWLOntologyManager();
	OWLDataFactory df = mgr.getOWLDataFactory();
	clearInformationContentCache();
	for (OWLAnnotationAssertionAxiom ax : o.getAxioms(AxiomType.ANNOTATION_ASSERTION)) {
		if (ax.getProperty().getIRI().toString().equals(icIRIString)) {
			OWLLiteral lit = (OWLLiteral) ax.getValue();
			OWLClass c = df.getOWLClass((IRI) ax.getSubject());
			Double v = lit.parseDouble();
			setInformtionContectForAttribute(c, v);
		}
	}
	assignDefaultInformationContentForAllClasses();
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:16,代碼來源:AbstractOwlSim.java

示例14: assertSubClass

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

示例15: testTinyOntology7

import org.semanticweb.owlapi.model.OWLOntologyManager; //導入方法依賴的package包/類
/**
 * <ol>
 * <li>A \u2291 &exist; r <i>.</i> B</li>
 * <li>B \u2291 &exist; r <i>.</i> C</li>
 * <li>C \u2291 &exist; s <i>.</i> D</li>
 * <li>D \u2291 &exist; s <i>.</i> E</li>
 * <li>E \u2291 &exist; s <i>.</i> &perp;</li>
 * </ol>
 * &vDash;
 * <ul>
 * <li>A &equiv; &perp;</li>
 * <li>B &equiv; &perp;</li>
 * <li>C &equiv; &perp;</li>
 * <li>D &equiv; &perp;</li>
 * <li>E &equiv; &perp;</li>
 * </ul>
 * 
 * @throws OWLOntologyCreationException
 *             if something goes wrong with the ontology creation
 */
@Test
public void testTinyOntology7() throws OWLOntologyCreationException {
	OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
	OWLDataFactory factory = manager.getOWLDataFactory();
	Set<OWLAxiom> axiomSet = new HashSet<>();
	OWLClass a = createNewClass(factory, "A");
	OWLClass b = createNewClass(factory, "B");
	OWLClass c = createNewClass(factory, "C");
	OWLClass d = createNewClass(factory, "D");
	OWLClass e = createNewClass(factory, "E");
	OWLObjectProperty r = createNewObjectProperty(factory, "r");
	OWLObjectProperty s = createNewObjectProperty(factory, "s");

	// 1
	axiomSet.add(factory.getOWLSubClassOfAxiom(a, factory.getOWLObjectSomeValuesFrom(r, b)));

	// 2
	axiomSet.add(factory.getOWLSubClassOfAxiom(b, factory.getOWLObjectSomeValuesFrom(r, c)));

	// 3
	axiomSet.add(factory.getOWLSubClassOfAxiom(c, factory.getOWLObjectSomeValuesFrom(s, d)));

	// 4
	axiomSet.add(factory.getOWLSubClassOfAxiom(d, factory.getOWLObjectSomeValuesFrom(s, e)));

	// 5
	axiomSet.add(factory.getOWLSubClassOfAxiom(e, factory.getOWLObjectSomeValuesFrom(s, factory.getOWLNothing())));

	OWLOntology ontology = manager.createOntology(axiomSet);
	JcelReasonerFactory reasonerFactory = new JcelReasonerFactory();
	OWLReasoner reasoner = reasonerFactory.createReasoner(ontology);

	Set<OWLClass> elementsToTest = new TreeSet<>();
	elementsToTest.add(a);
	elementsToTest.add(b);
	elementsToTest.add(c);
	elementsToTest.add(d);
	elementsToTest.add(e);
	elementsToTest.add(factory.getOWLNothing());

	elementsToTest.forEach(element -> {
		Set<OWLClass> equivalents = reasoner.getEquivalentClasses(element).getEntities();
		Assert.assertTrue(equivalents.contains(a));
		Assert.assertTrue(equivalents.contains(b));
		Assert.assertTrue(equivalents.contains(c));
		Assert.assertTrue(equivalents.contains(d));
		Assert.assertTrue(equivalents.contains(e));
		Assert.assertTrue(equivalents.contains(factory.getOWLNothing()));
	});

	verifyBottomAndTop(reasoner);

}
 
開發者ID:julianmendez,項目名稱:jcel,代碼行數:74,代碼來源:TinyOntologyTest.java


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