Package com.hp.hpl.jena.ontology

Examples of com.hp.hpl.jena.ontology.ObjectProperty


    model.prepare();

    String ns = "http://www.owl-ontologies.com/unnamed.owl#";
    Individual Forest_Service = model.getIndividual( ns + "Forest_Service" );
    ObjectProperty comprises = model.getObjectProperty( ns + "comprises" );
    Individual Executive = model.getIndividual( ns + "Executive" );
    Individual USDA = model.getIndividual( ns + "USDA" );

    assertTrue( "Forest_Service, comprises, Executive", model.contains( Forest_Service,
        comprises, Executive ) );
View Full Code Here


  public void testTransitiveSubProperty1() {
    String ns = "urn:test:";

    OntModel model = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );

    ObjectProperty knows = model.createObjectProperty( ns + "knows" );

    ObjectProperty hasRelative = model.createObjectProperty( ns + "hasRelative" );
    // a person knows all his/her relatives
    hasRelative.addSuperProperty( knows );
    // being a relative is transitive (but knowing someone is not
    // transitive)
    hasRelative.addRDFType( OWL.TransitiveProperty );

    ObjectProperty hasParent = model.createObjectProperty( ns + "hasParent" );
    // a parent is also a relative
    hasParent.addSuperProperty( hasRelative );

    OntClass cls = model.createClass( ns + "cls" );
    Individual a = cls.createIndividual( ns + "a" );
    Individual b = cls.createIndividual( ns + "b" );
    Individual c = cls.createIndividual( ns + "c" );
View Full Code Here

    String ns = "http://www.example.org/family#";

    OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC, null );
    model.read( base + "family.owl" );

    ObjectProperty hasBrother = model.getObjectProperty( ns + "hasBrother" );
    ObjectProperty hasSon = model.getObjectProperty( ns + "hasSon" );
    ObjectProperty hasFather = model.getObjectProperty( ns + "hasFather" );
    ObjectProperty hasParent = model.getObjectProperty( ns + "hasParent" );
    ObjectProperty hasChild = model.getObjectProperty( ns + "hasChild" );
    ObjectProperty hasMother = model.getObjectProperty( ns + "hasMother" );
    ObjectProperty hasDaughter = model.getObjectProperty( ns + "hasDaughter" );
    ObjectProperty hasAncestor = model.getObjectProperty( ns + "hasAncestor" );
    ObjectProperty likes = model.getObjectProperty( ns + "likes" );
    ObjectProperty isMarriedTo = model.getObjectProperty( ns + "isMarriedTo" );
    ObjectProperty dislikes = model.getObjectProperty( ns + "dislikes" );
    ObjectProperty hasSister = model.getObjectProperty( ns + "hasSister" );
    ObjectProperty hasDescendant = model.getObjectProperty( ns + "hasDescendant" );
    ObjectProperty hasSibling = model.getObjectProperty( ns + "hasSibling" );
    OntClass Child = model.getOntClass( ns + "Child" );
    OntClass Person = model.getOntClass( ns + "Person" );
    OntClass PersonWithAtLeastTwoMaleChildren = model.getOntClass( ns
        + "PersonWithAtLeastTwoMaleChildren" );
    OntClass PersonWithAtLeastTwoFemaleChildren = model.getOntClass( ns
View Full Code Here

    OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC, null );
    model.read( base + "dl-safe.owl" );

    // ObjectProperty father = model.getObjectProperty( ns + "father" );
    ObjectProperty hates = model.getObjectProperty( ns + "hates" );
    ObjectProperty sibling = model.getObjectProperty( ns + "sibling" );

    OntClass BadChild = model.getOntClass( ns + "BadChild" );
    OntClass Child = model.getOntClass( ns + "Child" );
    // OntClass GoodChild = model.getOntClass( ns + "GoodChild" );
    OntClass Grandchild = model.getOntClass( ns + "Grandchild" );
View Full Code Here

    String ns = "urn:test:";

    OntModel reasoner = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );

    ObjectProperty p = reasoner.createObjectProperty( ns + "p" );
    ObjectProperty subP = reasoner.createObjectProperty( ns + "subP" );
    ObjectProperty subSubP = reasoner.createObjectProperty( ns + "subSubP" );
   
    DatatypeProperty q = reasoner.createDatatypeProperty( ns + "q" );
    DatatypeProperty subQ = reasoner.createDatatypeProperty( ns + "subQ" );
    DatatypeProperty subSubQ = reasoner.createDatatypeProperty( ns + "subSubQ" );
   
   
    // create assertions in one RDF model
    Model assertions = ModelFactory.createDefaultModel();
    assertions.add( subP, RDFS.subPropertyOf, p );
    assertions.add( subSubP, RDFS.subPropertyOf, subP );
    assertions.add( subQ, RDFS.subPropertyOf, q );
    assertions.add( subSubQ, RDFS.subPropertyOf, subQ );

    // load the assertions to the reasoner
    reasoner.add( assertions );

    // create the inferences for testing in a separate RDF model
    Model inferences = ModelFactory.createDefaultModel();
    // all assertions should be inferred
    inferences.add( assertions );
    // rdfs:subPropertyOf is reflexive
    for( Property op : new Property[] { p, subP, subSubP, q, subQ, subSubQ } ) {
      inferences.add( op, RDFS.subPropertyOf, op );
    }
    // All object properties are a sub property of topObjectProperty
    for( Property op : new Property[] { p, subP, subSubP, OWL2.topObjectProperty, OWL2.bottomObjectProperty } ) {
      inferences.add( op, RDFS.subPropertyOf, OWL2.topObjectProperty );
      inferences.add( OWL2.bottomObjectProperty, RDFS.subPropertyOf, op );
    }
    // All data properties are a sub property of topDataProperty
    for( Property dp: new Property[] { q, subQ, subSubQ, OWL2.topDataProperty, OWL2.bottomDataProperty } ) {
      inferences.add( dp, RDFS.subPropertyOf, OWL2.topDataProperty );
      inferences.add( OWL2.bottomDataProperty, RDFS.subPropertyOf, dp );
    }
    // the real inferred relations
    inferences.add( subSubP, RDFS.subPropertyOf, p );
    inferences.add( subSubQ, RDFS.subPropertyOf, q );
    // check if all inferences hold
    assertPropertyValues( reasoner, RDFS.subPropertyOf, inferences );

    // check for direct sub-properties
    assertIteratorValues( p.listSubProperties( true ), new RDFNode[] { subP } );
    assertIteratorValues( subP.listSuperProperties( true ), new RDFNode[] { p } );
    assertIteratorValues( subP.listSubProperties( true ), new RDFNode[] { subSubP } );
    assertIteratorValues( subSubP.listSuperProperties( true ), new RDFNode[] { subP } );

    assertIteratorValues( q.listSubProperties( true ), new RDFNode[] { subQ } );
    assertIteratorValues( subQ.listSuperProperties( true ), new RDFNode[] { q } );
    assertIteratorValues( subQ.listSubProperties( true ), new RDFNode[] { subSubQ } );
    assertIteratorValues( subSubQ.listSuperProperties( true ), new RDFNode[] { subQ } );
View Full Code Here

    // check that the kb is now inconsistent and that incremental
    // consistency was used
    assertTrue( ((PelletInfGraph) model.getGraph()).isConsistent() );
    assertTrue( graph.getKB().timers.getTimer( "isIncConsistent" ).getCount() == 0 );

    ObjectProperty op = model.createObjectProperty( ns + "op" );
    i2.addProperty( op, i4 );

    model.prepare();

    // check that the kb is now inconsistent and that incremental
View Full Code Here

    OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );
    model.setStrictMode( false );

    DatatypeProperty dp = model.createDatatypeProperty( ns + "dp" );

    ObjectProperty op = model.createObjectProperty( ns + "op" );

    OntClass C = model.createClass( ns + "C" );
    Individual a = model.createIndividual( ns + "a", C );
    Individual b = model.createIndividual( ns + "b", C );
View Full Code Here

    OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );
    model.setStrictMode( false );

    DatatypeProperty dp = model.createDatatypeProperty( ns + "dp" );

    ObjectProperty op = model.createObjectProperty( ns + "op" );

    OntClass C = model.createClass( ns + "C" );
    Individual anon1 = model.createIndividual( C );
    Individual a = model.createIndividual( ns + "a", C );
View Full Code Here

  public void testSimplePropertyAssertion() { 
    String ns = "urn:test:";

    OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );

    ObjectProperty p = model.createObjectProperty( ns + "p" );
    ObjectProperty q = model.createObjectProperty( ns + "q" );
    Individual a = model.createIndividual( ns + "a", OWL.Thing );
    Individual b = model.createIndividual( ns + "b", OWL.Thing );

    // use a subproperty to make sure we get inferred results and not just
    // results from raw graph
View Full Code Here

  }

  public void testObjPropJenaToOwl() {
            JenaToOwlConvert j2o = new JenaToOwlConvert();
            OntModel model = ModelFactory.createOntologyModel();
            ObjectProperty jp = model.createObjectProperty(OP.toString());
            OWLObjectProperty wp = null;
            try{
            wp = j2o.ObjPropJenaToOwl(jp, RDFXML);
                if(wp == null){
                    fail("Some errors occurs");
                }else{
                  assertEquals(wp.getIRI().toURI().toString(), jp.getURI().toString());
                }
            }catch(Exception e){
                e.printStackTrace();
    fail("Exception caugth");
            } finally {
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.ontology.ObjectProperty

Copyright © 2018 www.massapicom. 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.