Package com.hp.hpl.jena.ontology

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


  @Test
  public void testDataPropCard1() {
    String ns = "urn:test:";

    OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );
    DatatypeProperty prop = model.createDatatypeProperty( ns + "prop" );
    OntClass C = model.createClass( ns + "C" );
    C.addSuperClass( model.createCardinalityRestriction( null, prop, 2 ) );
    Individual x = model.createIndividual( ns + "x", C );
    x.addProperty( prop, "literal" );
View Full Code Here


  @Test
  public void testDataPropCard2() {
    String ns = "urn:test:";

    OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );
    DatatypeProperty prop = model.createDatatypeProperty( ns + "prop" );
    OntClass C = model.createClass( ns + "C" );
    C.addSuperClass( model.createCardinalityRestriction( null, prop, 2 ) );
    Individual x = model.createIndividual( ns + "x", C );
    x.addProperty( prop, "literal1" );
    x.addProperty( prop, "literal2" );
View Full Code Here

  @Test
  public void testSubDataPropCard() {
    String ns = "urn:test:";

    OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );
    DatatypeProperty prop = model.createDatatypeProperty( ns + "prop" );
    DatatypeProperty sub = model.createDatatypeProperty( ns + "sub" );
    sub.addSuperProperty( prop );

    OntClass C = model.createClass( ns + "C" );
    C.addSuperClass( model.createCardinalityRestriction( null, prop, 2 ) );
    Individual x = model.createIndividual( ns + "x", C );
View Full Code Here

    model.prepare();

    Iterator<?> i = model.listDatatypeProperties();
    while( i.hasNext() ) {
      DatatypeProperty p = (DatatypeProperty) i.next();
      Iterator<?> j = p.listRange();
      while( j.hasNext() ) {
        Resource range = (Resource) j.next();
        assertTrue( TypeMapper.getInstance().getTypeByName( range.getURI() ) != null );
      }
    }
View Full Code Here

    String ns = "urn:test:";

    DatatypeReasoner dtReasoner = new DatatypeReasonerImpl();
    for( ATermAppl uri : dtReasoner.listDataRanges() ) {
      OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );
      DatatypeProperty prop = model.createDatatypeProperty( ns + "prop" );
      Resource datatype = model.createResource( uri.getName() );
      prop.addRange( datatype );
      OntClass C = model.createClass( ns + "C" );
      int cardinality = datatype.equals( XSD.xboolean )
        ? 2
        : 10;
      C.addSuperClass( model.createCardinalityRestriction( null, prop, cardinality ) );
View Full Code Here

    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

    Resource ni = XSD.negativeInteger;
    Resource pi = XSD.positiveInteger;
    Resource i = XSD.integer;
    Resource f = XSD.xfloat;
   
    DatatypeProperty s = model.createDatatypeProperty( ns + "s" );
   
    OntClass c1 = model.createClass( ns + "c1" );
    c1.addEquivalentClass( model.createSomeValuesFromRestriction( null, s, pi ) );
    assertFalse( model.contains( c1, RDFS.subClassOf, OWL2.Nothing ) );
   
    OntClass c2 = model.createClass( ns + "c2" );
    Resource b2 = model.createResource();
    model.add(b2, RDF.type, OWL2.DataRange);
    model.add(b2, OWL2.datatypeComplementOf, pi);
    c2.addEquivalentClass( model.createSomeValuesFromRestriction( null, s, b2 ) );
    assertFalse( model.contains( c2, RDFS.subClassOf, OWL2.Nothing ) );
   
    OntClass c3 = model.createClass( ns + "c3" );
    RDFNode[] l3 = new RDFNode[2];
    l3[0] = pi;
    l3[1] = ni;
    c3.addEquivalentClass( model.createSomeValuesFromRestriction( null, s, model.createIntersectionClass( null, model.createList( l3 ) ) ) );
    assertTrue( model.contains(c3, RDFS.subClassOf, OWL2.Nothing ) );
   
    OntClass c4 = model.createClass( ns + "c4" );
    RDFNode[] l41 = new RDFNode[2];
    l41[0] = pi;
    l41[1] = ni;
    RDFNode[] l42 = new RDFNode[2];
    l42[0] = f;
    l42[1] = model.createUnionClass( null, model.createList( l41 ) );
    c4.addEquivalentClass( model.createSomeValuesFromRestriction( null, s, model.createIntersectionClass( null, model.createList( l42 ) ) ) );
    assertTrue( model.contains(c4, RDFS.subClassOf, OWL2.Nothing ) );
   
    OntClass c5 = model.createClass( ns + "c5" );
    RDFNode[] l5 = new RDFNode[2];
    l5[0] = npi;
    l5[1] = ni;
    c5.addEquivalentClass( model.createSomeValuesFromRestriction( null, s, model.createIntersectionClass( null, model.createList( l5 ) ) ) );
    assertFalse( model.contains(c5, RDFS.subClassOf, OWL2.Nothing ) );
   
    OntClass c6 = model.createClass( ns + "c6" );
    RDFNode[] l6 = new RDFNode[2];
    l6[0] = nni;
    l6[1] = pi;
    c6.addEquivalentClass( model.createSomeValuesFromRestriction( null, s, model.createIntersectionClass( null, model.createList( l6 ) ) ) );
    assertFalse( model.contains(c6, RDFS.subClassOf, OWL2.Nothing ) );
   
    OntClass c7 = model.createClass( ns + "c7" );
    RDFNode[] l7 = new RDFNode[2];
    l7[0] = nni;
    l7[1] = npi;
    c7.addEquivalentClass( model.createSomeValuesFromRestriction( null, s, model.createUnionClass( null, model.createList( l7 ) ) ) );
    assertFalse( model.contains(c7, RDFS.subClassOf, OWL2.Nothing ) );
   
    OntClass c8 = model.createClass( ns + "c8" );
    RDFNode[] l8 = new RDFNode[2];
    l8[0] = nni;
    l8[1] = npi;
    c8.addEquivalentClass( model.createSomeValuesFromRestriction( null, s, model.createIntersectionClass( null, model.createList( l8 ) ) ) );
    assertFalse( model.contains(c8, RDFS.subClassOf, OWL2.Nothing ) );
   
    OntClass c9 = model.createClass( ns + "c9" );
    Resource fr9 = model.createResource();
    model.add( fr9, OWL2.maxExclusive, model.createTypedLiteral( 0 ) );
    Resource b9 = model.createResource();
    model.add( b9, RDF.type, RDFS.Datatype);
    model.add( b9, OWL2.onDatatype, i);
    model.add( b9, OWL2.withRestrictions, model.createList( new RDFNode[] { fr9 } ));
    RDFNode[] l9 = new RDFNode[2];
    l9[0] = pi;
    l9[1] = b9;
    c9.addEquivalentClass( model.createSomeValuesFromRestriction( null, s, model.createIntersectionClass( null, model.createList( l9 ) ) ) );
    assertTrue( model.contains(c9, RDFS.subClassOf, OWL2.Nothing ) );
   
    OntClass c10 = model.createClass( ns + "c10" );
    DatatypeProperty p = model.createDatatypeProperty( ns + "p" );
    Resource b10 = model.createResource();
    model.add( b10, RDF.type, RDFS.Datatype);
    model.add( b10, OWL.unionOf, model.createList( new RDFNode[] { pi, ni } ));
    model.add(p, RDFS.range, b10 );
    c10.addEquivalentClass( model.createSomeValuesFromRestriction( null, p, XSD.anyURI ) );
View Full Code Here

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

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

    DatatypeProperty p = model.createDatatypeProperty( ns + "p" );
    p.addRDFType( OWL.InverseFunctionalProperty );
    p.addRange( XSD.xboolean );

    OntClass C = model.createClass( ns + "C" );
    C.addSuperClass( model.createCardinalityRestriction( null, p, 1 ) );

    Individual i1 = model.createIndividual( ns + "i1", C );
View Full Code Here

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

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

    DatatypeProperty p = model.createDatatypeProperty( ns + "p" );
    p.addRDFType( OWL.InverseFunctionalProperty );
    p.addRange( XSD.xboolean );

    OntClass C = model.createClass( ns + "C" );
    C.addSuperClass( model.createCardinalityRestriction( null, p, 1 ) );

    OntClass D = model.createClass( ns + "D" );
View Full Code Here

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

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

TOP

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

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.