Examples of OWLDataFactory


Examples of org.semanticweb.owlapi.model.OWLDataFactory

        // Now we want to specify that A is a subclass of B. To do this, we add
        // a subclass axiom. A subclass axiom is simply an object that specifies
        // that one class is a subclass of another class. We need a data factory
        // to create various object from. Each manager has a reference to a data
        // factory that we can use.
        OWLDataFactory factory = manager.getOWLDataFactory();
        // Get hold of references to class A and class B. Note that the ontology
        // does not contain class A or classB, we simply get references to
        // objects from a data factory that represent class A and class B
        OWLClass clsA = factory.getOWLClass(IRI.create(ontologyIRI + "#A"));
        OWLClass clsB = factory.getOWLClass(IRI.create(ontologyIRI + "#B"));
        // Now create the axiom
        OWLAxiom axiom = factory.getOWLSubClassOfAxiom(clsA, clsB);
        // We now add the axiom to the ontology, so that the ontology states
        // that A is a subclass of B. To do this we create an AddAxiom change
        // object. At this stage neither classes A or B, or the axiom are
        // contained in the ontology. We have to add the axiom to the ontology.
        AddAxiom addAxiom = new AddAxiom(ontology, axiom);
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLDataFactory

        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        IRI ontologyIRI = IRI.create("http://example.com/owl/families/");
        OWLOntology ontology = manager.createOntology(ontologyIRI);
        // Get hold of a data factory from the manager and set up a prefix
        // manager to make things easier
        OWLDataFactory factory = manager.getOWLDataFactory();
        PrefixManager pm = new DefaultPrefixManager(null, null,
                ontologyIRI.toString());
        // Let's specify the :John has a wife :Mary Get hold of the necessary
        // individuals and object property
        OWLNamedIndividual john = factory.getOWLNamedIndividual(":John", pm);
        OWLNamedIndividual mary = factory.getOWLNamedIndividual(":Mary", pm);
        OWLObjectProperty hasWife = factory
                .getOWLObjectProperty(":hasWife", pm);
        // To specify that :John is related to :Mary via the :hasWife property
        // we create an object property assertion and add it to the ontology
        OWLObjectPropertyAssertionAxiom propertyAssertion = factory
                .getOWLObjectPropertyAssertionAxiom(hasWife, john, mary);
        manager.addAxiom(ontology, propertyAssertion);
        // Now let's specify that :John is aged 51. Get hold of a data property
        // called :hasAge
        OWLDataProperty hasAge = factory.getOWLDataProperty(":hasAge", pm);
        // To specify that :John has an age of 51 we create a data property
        // assertion and add it to the ontology
        OWLDataPropertyAssertionAxiom dataPropertyAssertion = factory
                .getOWLDataPropertyAssertionAxiom(hasAge, john, 51);
        manager.addAxiom(ontology, dataPropertyAssertion);
        // Note that the above is a shortcut for creating a typed literal and
        // specifying this typed literal as the value of the property assertion.
        // That is, Get hold of the xsd:integer datatype
        OWLDatatype integerDatatype = factory
                .getOWLDatatype(OWL2Datatype.XSD_INTEGER.getIRI());
        // Create a typed literal. We type the literal "51" with the datatype
        OWLLiteral literal = factory.getOWLLiteral("51", integerDatatype);
        // Create the property assertion and add it to the ontology
        OWLAxiom ax = factory.getOWLDataPropertyAssertionAxiom(hasAge, john,
                literal);
        manager.addAxiom(ontology, ax);
        // Dump the ontology to System.out
        manager.saveOntology(ontology, new StreamDocumentTarget(
                new ByteArrayOutputStream()));
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLDataFactory

    protected OWLEntityChecker entityChecker;
    private ParserWrapper parser;

    @Before
    public void setUp() {
        OWLDataFactory dataFactory = new OWLDataFactoryImpl();
        OWLClass cls = mock(OWLClass.class);
        when(cls.getIRI()).thenReturn(mock(IRI.class));
        when(entityChecker.getOWLClass("C")).thenReturn(cls);
        OWLClass clsC1 = mock(OWLClass.class);
        when(clsC1.getIRI()).thenReturn(mock(IRI.class));
        when(entityChecker.getOWLClass("C1")).thenReturn(clsC1);
        OWLObjectProperty oP = mock(OWLObjectProperty.class);
        when(oP.getIRI()).thenReturn(mock(IRI.class));
        when(oP.asOWLObjectProperty()).thenReturn(oP);
        when(entityChecker.getOWLObjectProperty("oP")).thenReturn(oP);
        when(entityChecker.getOWLDataProperty("dP")).thenReturn(
                mock(OWLDataProperty.class));
        when(entityChecker.getOWLAnnotationProperty("aP")).thenReturn(
                mock(OWLAnnotationProperty.class));
        when(entityChecker.getOWLAnnotationProperty("rdfs:comment"))
                .thenReturn(dataFactory.getRDFSComment());
        OWLNamedIndividual ind = mock(OWLNamedIndividual.class);
        when(entityChecker.getOWLIndividual("ind")).thenReturn(ind);
        when(ind.asOWLNamedIndividual()).thenReturn(ind);
        parser = new ParserWrapper();
    }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLDataFactory

@SuppressWarnings("javadoc")
public class FunctionalSyntaxIRIProblemTestCase extends TestBase {

    @Test
    public void testmain() throws Exception {
        OWLDataFactory factory = m.getOWLDataFactory();
        OWLOntology ontology = m.createOntology(IRI("urn:testontology:o1"));
        OWLObjectProperty p = factory
                .getOWLObjectProperty(IRI("http://example.org/A_#part_of"));
        OWLClass a = Class(IRI("http://example.org/A_A"));
        OWLClass b = Class(IRI("http://example.org/A_B"));
        m.addAxiom(ontology, Declaration(p));
        m.addAxiom(ontology, Declaration(a));
        m.addAxiom(ontology, Declaration(b));
        m.addAxiom(ontology,
                SubClassOf(b, factory.getOWLObjectSomeValuesFrom(p, a)));
        OWLOntology loadOntology = roundTrip(ontology,
                new RDFXMLDocumentFormat());
        FunctionalSyntaxDocumentFormat functionalFormat = new FunctionalSyntaxDocumentFormat();
        functionalFormat.asPrefixOWLOntologyFormat().setPrefix("example",
                "http://example.org/");
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLDataFactory

                        .create(ontologyByVersion))));
        manager.saveOntology(ontology, IRI.create(ontologyByName));
        manager.saveOntology(ontology, IRI.create(ontologyByVersion));
        manager.saveOntology(ontology, IRI.create(ontologyByOtherPath));
        manager = m1;
        OWLDataFactory factory = manager.getOWLDataFactory();
        OWLOntology ontology1 = manager.createOntology(IRI
                .create(importsBothNameAndVersion));
        OWLOntology ontology2 = manager.createOntology(IRI
                .create(importsBothNameAndOther));
        List<AddImport> changes = new ArrayList<>();
        changes.add(new AddImport(ontology1, factory
                .getOWLImportsDeclaration(IRI.create(ontologyByName))));
        changes.add(new AddImport(ontology1, factory
                .getOWLImportsDeclaration(IRI.create(ontologyByVersion))));
        changes.add(new AddImport(ontology2, factory
                .getOWLImportsDeclaration(IRI.create(ontologyByName))));
        changes.add(new AddImport(ontology2, factory
                .getOWLImportsDeclaration(IRI.create(ontologyByOtherPath))));
        manager.applyChanges(changes);
        manager.saveOntology(ontology1, IRI.create(importsBothNameAndVersion));
        manager.saveOntology(ontology2, IRI.create(importsBothNameAndOther));
        // when
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLDataFactory

     */
    @Nonnull
    public OWLAnnotation getAnnotationForTagValuePair(String tagName,
            String value) {
        IRI tagIRI = getTagIRI(tagName);
        OWLDataFactory df = getDataFactory();
        OWLAnnotationProperty annotationProperty = df
                .getOWLAnnotationProperty(tagIRI);
        String unescapedString = getUnquotedString(value);
        OWLLiteral annotationValue = df.getOWLLiteral(unescapedString);
        return df.getOWLAnnotation(annotationProperty, annotationValue);
    }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLDataFactory

public class ExpandExpressionGCITest extends OboFormatTestBasics {

    @Test
    public void testExpand() {
        OWLOntology ontology = convert(parseOBOFile("no_overlap.obo"));
        OWLDataFactory df = ontology.getOWLOntologyManager()
                .getOWLDataFactory();
        MacroExpansionGCIVisitor mev = new MacroExpansionGCIVisitor(ontology,
                OWLManager.createOWLOntologyManager());
        OWLOntology gciOntology = mev.createGCIOntology();
        int axiomCount = gciOntology.getAxiomCount();
        assertTrue(axiomCount > 0);
        OWLClass cls = df.getOWLClass(IRI
                .create("http://purl.obolibrary.org/obo/TEST_2"));
        Set<OWLDisjointClassesAxiom> dcas = gciOntology
                .getDisjointClassesAxioms(cls);
        assertEquals(1, dcas.size());
        Set<OWLEquivalentClassesAxiom> equivalentClassesAxioms = gciOntology
                .getAxioms(AxiomType.EQUIVALENT_CLASSES);
        assertEquals(2, equivalentClassesAxioms.size());
        for (OWLEquivalentClassesAxiom eca : equivalentClassesAxioms) {
            Set<OWLClassExpression> ces = eca.getClassExpressions();
            OWLClass clst4 = df.getOWLClass(IRI
                    .create("http://purl.obolibrary.org/obo/TEST_4"));
            OWLObjectPropertyExpression p = df.getOWLObjectProperty(IRI
                    .create("http://purl.obolibrary.org/obo/RO_0002104"));
            OWLClassExpression cet4 = df.getOWLObjectSomeValuesFrom(p, clst4);
            OWLClass clst5 = df.getOWLClass(IRI
                    .create("http://purl.obolibrary.org/obo/TEST_5"));
            OWLClassExpression cet5 = df.getOWLObjectSomeValuesFrom(p, clst5);
            if (ces.contains(cet4)) {
                ces.remove(cet4);
                OWLClassExpression clst4ex = ces.iterator().next();
                assertEquals(
                        "ObjectSomeValuesFrom(<http://purl.obolibrary.org/obo/BFO_0000051> ObjectIntersectionOf(<http://purl.obolibrary.org/obo/GO_0005886> ObjectSomeValuesFrom(<http://purl.obolibrary.org/obo/BFO_0000051> <http://purl.obolibrary.org/obo/TEST_4>)))",
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLDataFactory

public class ExpandExpressionTest extends OboFormatTestBasics {

    @Test
    public void testExpand() {
        OWLOntology ontology = convert(parseOBOFile("no_overlap.obo"));
        OWLDataFactory df = ontology.getOWLOntologyManager()
                .getOWLDataFactory();
        MacroExpansionVisitor mev = new MacroExpansionVisitor(ontology);
        OWLOntology outputOntology = mev.expandAll();
        OWLClass cls = df.getOWLClass(IRI
                .create("http://purl.obolibrary.org/obo/TEST_2"));
        Set<OWLDisjointClassesAxiom> dcas = outputOntology
                .getDisjointClassesAxioms(cls);
        // System.out.println(dcas);
        assertEquals(1, dcas.size());
        cls = df.getOWLClass(IRI
                .create("http://purl.obolibrary.org/obo/TEST_3"));
        Set<OWLSubClassOfAxiom> scas = outputOntology
                .getSubClassAxiomsForSubClass(cls);
        // System.out.println(scas);
        assertEquals(1, scas.size());
        assertEquals(
                "[SubClassOf(<http://purl.obolibrary.org/obo/TEST_3> ObjectSomeValuesFrom(<http://purl.obolibrary.org/obo/BFO_0000051> ObjectIntersectionOf(<http://purl.obolibrary.org/obo/GO_0005886> ObjectSomeValuesFrom(<http://purl.obolibrary.org/obo/BFO_0000051> <http://purl.obolibrary.org/obo/TEST_4>))))]",
                scas.toString());
        cls = df.getOWLClass(IRI
                .create("http://purl.obolibrary.org/obo/TEST_4"));
        Set<OWLEquivalentClassesAxiom> ecas = outputOntology
                .getEquivalentClassesAxioms(cls);
        boolean ok = false;
        for (OWLEquivalentClassesAxiom eca : ecas) {
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLDataFactory

    @Nonnull
    private OWLAnnotationAssertionAxiom convertToAnnotation(
            @Nonnull OWLNamedIndividual ind,
            @Nonnull OWLDataPropertyAssertionAxiom ax) {
        OWLDataFactory df = getDataFactory();
        OWLAnnotation anno = df.getOWLAnnotation(
                df.getOWLAnnotationProperty(ax.getProperty()
                        .asOWLDataProperty().getIRI()), ax.getObject());
        return df.getOWLAnnotationAssertionAxiom(ind.getIRI(), anno);
    }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLDataFactory

    @Test
    public void testUnion() {
        OWLOntology owlOnt = convertOBOFile("taxon_union_terms.obo");
        assertNotNull(owlOnt);
        OWLOntologyManager manager = owlOnt.getOWLOntologyManager();
        OWLDataFactory df = manager.getOWLDataFactory();
        IRI iri = IRI
                .create("http://purl.obolibrary.org/obo/NCBITaxon_Union_0000000");
        OWLClass cls = df.getOWLClass(iri);
        boolean ok = false;
        for (OWLEquivalentClassesAxiom ax : owlOnt
                .getEquivalentClassesAxioms(cls)) {
            for (OWLClassExpression ex : ax.getClassExpressions()) {
                if (ex instanceof OWLObjectUnionOf) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.