Package com.hp.hpl.jena.ontology

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


    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" );

    model.prepare();

    assertTrue( ((PelletInfGraph) model.getGraph()).isConsistent() );
  }
View Full Code Here


    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" );
    x.addProperty( prop, "literal3" );

    assertTrue( !model.validate().isValid() );
  }
View Full Code Here

    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 );

    Literal val1 = model.createLiteral( "val1" );
    x.addProperty( prop, val1 );
    Literal val2 = model.createLiteral( "val2" );
    x.addProperty( sub, val2 );

    assertTrue( model.validate().isValid() );

    assertPropertyValues( model, x, prop, val1, val2 );
  }
View Full Code Here

    String ns = "urn:test:";

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

    OntClass Country = model.createClass( ns + "Country" );
    Individual USA = model.createIndividual( ns + "USA", Country );
    Individual UnitedStates = model.createIndividual( ns + "UnitedStates", Country );

    OntProperty livesIn = model.createObjectProperty( ns + "livesIn" );
    livesIn.convertToFunctionalProperty();

    OntClass Person = model.createClass( ns + "Person" );
    Individual JohnDoe = model.createIndividual( ns + "JohnDoe", Person );
    JohnDoe.addProperty( livesIn, USA );
    JohnDoe.addProperty( livesIn, UnitedStates );

    assertTrue( model.contains( JohnDoe, RDF.type, Person ) );
    assertTrue( model.contains( USA, OWL.sameAs, UnitedStates ) );
    assertIteratorValues( model.listObjectsOfProperty( JohnDoe, livesIn ), new Resource[] {
        USA, UnitedStates } );
View Full Code Here

    model.prepare();

    assertTrue( ((PelletInfGraph) model.getGraph()).getKB().isConsistent() );

    Individual jdl62 = model.getIndividual( ns + "JDL_00062" );
    Individual jdl63 = model.getIndividual( ns + "JDL_00063" );

    assertTrue( jdl62.isSameAs( jdl63 ) );
    assertTrue( jdl63.isSameAs( jdl62 ) );

    assertIteratorValues( jdl62.listSameAs(), new Resource[] { jdl62, jdl63 } );

    assertIteratorValues( jdl63.listSameAs(), new Resource[] { jdl62, jdl63 } );

    model.getDocumentManager().setProcessImports( true );
    // ((PelletInfGraph) model.getGraph()).getKB().timers.print();
  }
View Full Code Here

    assertTrue( model.validate().isValid() );

    OntClass ThingWithFloatValue = model.getOntClass( ns + "ThingWithFloatValue" );
    OntClass ThingWithFloatProbability = model.getOntClass( ns + "ThingWithProbabilityValue" );

    Individual exampleThingWithFloatValue = model.getIndividual( ns
        + "exampleThingWithFloatValue" );
    Individual exampleThingWithFloatProbability = model.getIndividual( ns
        + "exampleThingWithProbabilityValue" );

    assertTrue( ThingWithFloatValue.hasSubClass( ThingWithFloatProbability ) );
    assertTrue( !ThingWithFloatProbability.hasSubClass( ThingWithFloatValue ) );

    assertTrue( exampleThingWithFloatValue.hasRDFType( ThingWithFloatValue ) );
    assertTrue( !exampleThingWithFloatValue.hasRDFType( ThingWithFloatProbability ) );

    assertTrue( exampleThingWithFloatProbability.hasRDFType( ThingWithFloatValue ) );
    assertTrue( exampleThingWithFloatProbability.hasRDFType( ThingWithFloatProbability ) );
  }
View Full Code Here

    OntClass ThingWithDecimalValue = model.getOntClass( ns + "ThingWithDecimalValue" );
    OntClass ThingWithDecimalProbability = model.getOntClass( ns
        + "ThingWithDecimalProbability" );
    OntClass ThingWithIntegerValue = model.getOntClass( ns + "ThingWithIntegerValue" );

    Individual exampleThingWithDecimalValue = model.getIndividual( ns
        + "exampleThingWithDecimalValue" );
    Individual exampleThingWithDecimalProbability = model.getIndividual( ns
        + "exampleThingWithDecimalProbability" );

    assertTrue( ThingWithDecimalValue.hasSubClass( ThingWithIntegerValue ) );
    assertTrue( ThingWithDecimalValue.hasSubClass( ThingWithDecimalProbability ) );

    assertTrue( exampleThingWithDecimalValue.hasRDFType( ThingWithDecimalValue ) );

    assertTrue( exampleThingWithDecimalProbability.hasRDFType( ThingWithIntegerValue ) );
    assertTrue( exampleThingWithDecimalProbability.hasRDFType( ThingWithDecimalProbability ) );
    assertTrue( exampleThingWithDecimalProbability.hasRDFType( ThingWithDecimalValue ) );

    assertTrue(!ThingWithDecimalValue.hasSuperClass(ThingWithIntegerValue));
    assertTrue(!ThingWithIntegerValue.hasSubClass(ThingWithDecimalProbability));
  }
View Full Code Here

        XSD.integer, "77", XSD.xlong, "214", XSD.negativeInteger, "-123",
        XSD.nonNegativeInteger, "2", XSD.nonPositiveInteger, "0", XSD.positiveInteger,
        "500", XSD.xshort, "476", XSD.xstring, "Test", XSD.time, "13:02:00", };

    OntModel model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC );
    Individual ind = model.createIndividual( ns + "test", OWL.Thing );
    for( int i = 0; i < datatypes.length; ) {
      Resource datatype = (Resource) datatypes[i++];
      OntProperty p = model.createDatatypeProperty( ns + "prop_" + datatype.getLocalName() );
      p.addRange( datatype );

      while( i < datatypes.length && datatypes[i] instanceof String ) {
        Literal value = model.createTypedLiteral( (String) datatypes[i], datatype.getURI() );
        ind.addProperty( p, value );
        i++;
      }
    }

    model.prepare();
View Full Code Here

        Resource datatype = (Resource) datatypes[i++];

        while( i < datatypes.length && datatypes[i] instanceof String ) {
          OntModel model = ModelFactory
              .createOntologyModel( PelletReasonerFactory.THE_SPEC );
          Individual ind = model.createIndividual( ns + "test", OWL.Thing );

          OntProperty p = model.createDatatypeProperty( ns + "prop_"
              + datatype.getLocalName() );
          if( addRangeRestriction ) {
                      p.addRange( datatype );
                    }

          Literal value = model.createTypedLiteral( (String) datatypes[i], datatype
              .getURI() );
          ind.addProperty( p, value );

          assertFalse( value.getLexicalForm() + " should not belong to "
              + datatype.getLocalName(), model.validate().isValid() );
          i++;
        }
View Full Code Here

      OntProperty p = model.createDatatypeProperty( ns + "prop" );
      p.addRange( datatype );

      int start = i;
      while( i < datatypes.length && datatypes[i] instanceof String ) {
        Individual ind = model.createIndividual( ns + "testInd" + i, OWL.Thing );
        Literal value = model.createTypedLiteral( (String) datatypes[i], datatype.getURI() );
        ind.addProperty( p, value );

        OntClass c = model.createClass( ns + "testCls" + i );
        c.addEquivalentClass( model.createHasValueRestriction( null, p, value ) );

        i++;
View Full Code Here

TOP

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

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.