Examples of OWLLiteral


Examples of org.semanticweb.owlapi.model.OWLLiteral

        // Now create the data range which correponds to int greater than 18. To
        // do this, we get hold of the int datatype and then restrict it with a
        // minInclusive facet restriction.
        OWLDatatype intDatatype = factory.getIntegerOWLDatatype();
        // Create the value "18", which is an int.
        OWLLiteral eighteenConstant = factory.getOWLLiteral(18);
        // Now create our custom datarange, which is int greater than or equal
        // to 18. To do this, we need the minInclusive facet
        OWLFacet facet = MIN_INCLUSIVE;
        // Create the restricted data range by applying the facet restriction
        // with a value of 18 to int
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLLiteral

    @Test
    public void shouldInstantiateLiterals() {
        OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
        OWLDataFactory factory = manager.getOWLDataFactory();
        // Get an plain literal with an empty language tag
        OWLLiteral literal1 = factory.getOWLLiteral("My string literal", "");
        // Get an untyped string literal with a language tag
        OWLLiteral literal2 = factory.getOWLLiteral("My string literal", "en");
        // Typed literals are literals that are typed with a datatype Create a
        // typed literal to represent the integer 33
        OWLDatatype integerDatatype = factory
                .getOWLDatatype(OWL2Datatype.XSD_INTEGER.getIRI());
        OWLLiteral literal3 = factory.getOWLLiteral("33", integerDatatype);
        // There is are short cut methods on OWLDataFactory for creating typed
        // literals with common datatypes Internallym these methods create
        // literals as above Create a literal to represent the integer 33
        OWLLiteral literal4 = factory.getOWLLiteral(33);
        // Create a literal to represent the double 33.3
        OWLLiteral literal5 = factory.getOWLLiteral(33.3);
        // Create a literal to represent the boolean value true
        OWLLiteral literal6 = factory.getOWLLiteral(true);
    }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLLiteral

        // 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
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLLiteral

        // comments and labels, so the creation of the annotation is a bit more
        // involved. First we'll create a constant for the annotation value.
        // Version info should probably contain a version number for the
        // ontology, but in this case, we'll add some text to describe why the
        // version has been updated
        OWLLiteral lit = df.getOWLLiteral("Added a comment to the pizza class");
        // The above constant is just a plain literal containing the version
        // info text/comment we need to create an annotation, which pairs a URI
        // with the constant
        OWLAnnotation anno = df.getOWLAnnotation(df
                .getOWLAnnotationProperty(OWLRDFVocabulary.OWL_VERSION_INFO
                        .getIRI()), lit);
        // Now we can add this as an ontology annotation Apply the change in the
        // usual way
        man.applyChange(new AddOntologyAnnotation(ont, anno));
        // The pizza ontology has labels attached to most classes which are
        // translations of class names into Portuguese (pt) we can access these
        // and print them out. At this point, it is worth noting that constants
        // can be typed or untyped. If constants are untyped then they can have
        // language tags, which are optional - typed constant cannot have
        // language tags. For each class in the ontology, we retrieve its
        // annotations and sift through them. If the annotation annotates the
        // class with a constant which is untyped then we check the language tag
        // to see if it is Portugeuse. Firstly, get the annotation property for
        // rdfs:label
        OWLAnnotationProperty label = df
                .getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI());
        for (OWLClass cls : ont.getClassesInSignature()) {
            // Get the annotations on the class that use the label property
            for (OWLAnnotation annotation : annotations(ont.filterAxioms(
                    Filters.annotations, cls.getIRI(), INCLUDED), label)) {
                if (annotation.getValue() instanceof OWLLiteral) {
                    OWLLiteral val = (OWLLiteral) annotation.getValue();
                    if (val.hasLang("pt")) {
                        // System.out.println(cls + " -> " + val.getLiteral());
                    }
                }
            }
        }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLLiteral

        // In the above code, 33 is an integer, so we can just pass 33 into the
        // data factory method. Behind the scenes the OWL API will create a
        // typed constant that it will use as the value of the data property
        // assertion. We could have manually created the constant as follows:
        OWLDatatype intDatatype = factory.getIntegerOWLDatatype();
        OWLLiteral thirtyThree = factory.getOWLLiteral("33", intDatatype);
        // We would then create the axiom as follows:
        factory.getOWLDataPropertyAssertionAxiom(hasAge, john, thirtyThree);
        // However, the convenice method is much shorter! We can now create the
        // other facts/assertion for Mary. The OWL API uses a change object
        // model, which means we can stack up changes (or sets of axioms) and
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLLiteral

        OWLOntology o = m.createOntology();
        OWLDataProperty p = m.getOWLDataFactory().getOWLDataProperty(
                IRI("urn:test#p"));
        OWLIndividual i = m.getOWLDataFactory().getOWLNamedIndividual(
                IRI("urn:test#ind"));
        OWLLiteral l = m.getOWLDataFactory().getOWLLiteral("test",
                OWL2Datatype.RDF_PLAIN_LITERAL);
        m.addAxiom(o,
                m.getOWLDataFactory().getOWLDataPropertyAssertionAxiom(p, i, l));
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        m.saveOntology(o, out);
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLLiteral

    @Test
    public void testPlainLiteralSerializationComments() throws Exception {
        OWLOntology o = m.createOntology();
        OWLIndividual i = df.getOWLNamedIndividual(IRI("urn:test#ind"));
        OWLLiteral l = m.getOWLDataFactory().getOWLLiteral("test",
                OWL2Datatype.RDF_PLAIN_LITERAL);
        m.addAxiom(o, df.getOWLAnnotationAssertionAxiom(df.getRDFSComment(), i
                .asOWLNamedIndividual().getIRI(), l));
        String expected = "<rdfs:comment>test</rdfs:comment>";
        assertTrue(saveOntology(o).toString().contains(expected));
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLLiteral

    }

    @Test
    public void testPlainLiteralSerializationComments2() throws Exception {
        OWLOntology o = m.createOntology();
        OWLLiteral l = m.getOWLDataFactory().getOWLLiteral("test",
                OWL2Datatype.RDF_PLAIN_LITERAL);
        OWLAnnotation a = m.getOWLDataFactory().getOWLAnnotation(
                m.getOWLDataFactory().getRDFSComment(), l);
        m.applyChange(new AddOntologyAnnotation(o, a));
        ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLLiteral

                            argIRI);
                }
                return dataFactory.getSWRLVariable(argIRI);
            } else {
                // Must be a literal
                OWLLiteral con = consumer.getLiteralObject(mainIRI,
                        argPredicateIRI, true);
                if (con != null) {
                    return dataFactory.getSWRLLiteralArgument(con);
                }
            }
View Full Code Here

Examples of org.semanticweb.owlapi.model.OWLLiteral

        body.add(df.getSWRLClassAtom(Class(iri("D")), indIArg));
        body.add(df.getSWRLClassAtom(Class(iri("B")), varX));
        SWRLVariable varQ = df.getSWRLVariable(IRI("http://www.owlapi#q"));
        SWRLVariable varR = df.getSWRLVariable(IRI("http://www.owlapi#r"));
        body.add(df.getSWRLDataPropertyAtom(DataProperty(iri("d")), varX, varQ));
        OWLLiteral lit = Literal(33);
        SWRLLiteralArgument litArg = df.getSWRLLiteralArgument(lit);
        body.add(df.getSWRLDataPropertyAtom(DataProperty(iri("d")), varY,
                litArg));
        Set<SWRLAtom> head = new HashSet<>();
        head.add(df.getSWRLClassAtom(Class(iri("C")), varX));
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.