Package org.semanticweb.owlapi.model

Examples of org.semanticweb.owlapi.model.OWLNamedIndividual


      Map<String, ? extends TestCase<?>> tests) {

    List<TestRunResult> results = new ArrayList<TestRunResult>();

    for( OWLClassAssertionAxiom axiom : o.getClassAssertionAxioms( TEST_RUN.getOWLClass() ) ) {
      final OWLNamedIndividual i = axiom.getIndividual().asOWLNamedIndividual();
      final Map<OWLObjectPropertyExpression, Set<OWLIndividual>> oValues = i
          .getObjectPropertyValues( o );

      Set<OWLIndividual> testObjects = oValues.get( TEST.getOWLObjectProperty() );
      if( testObjects.size() != 1 ) {
        log.warning( format(
            "Skipping result, missing or more than one test assertion (\"%s\",%s)", i
                .getIRI(), testObjects ) );
        continue;
      }
      Map<OWLDataPropertyExpression, Set<OWLLiteral>> testDValues = testObjects.iterator()
          .next().getDataPropertyValues( o );

      Set<OWLLiteral> ids = testDValues.get( IDENTIFIER.getOWLDataProperty() );
      TestCase<?> testCase = null;
      for( OWLLiteral c : ids ) {
        String id = c.getLiteral();
        testCase = tests.get( id );
        if( testCase != null )
          break;
      }

      if( testCase == null ) {
        log.warning( format( "Skipping result, no matching test case found (\"%s\",%s)", i
            .getIRI(), ids ) );
        continue;
      }

      Set<OWLIndividual> runnerIris = oValues.get( RUNNER.getOWLObjectProperty() );
      TestRunner<?> runner = null;
      if( runnerIris.size() != 1 ) {
        log
            .warning( format(
                "Skipping result, missing or more than one test runner assertion (\"%s\",%s)",
                i.getIRI(), runnerIris ) );
        continue;
      }
      runner = getRunner( runnerIris.iterator().next().asOWLNamedIndividual(), o );

      Set<OWLClassExpression> types = i.getTypes( o );

      RunResultType resultType = null;
      for( RunResultType t : RunResultType.values() ) {
        if( types.contains( t.getOWLClass() ) ) {
          resultType = t;
          break;
        }
      }
      if( resultType == null ) {
        log.warning( format( "Skipping result, missing result type (\"%s\")", i.getIRI() ) );
        continue;
      }

      @SuppressWarnings("unchecked")
      Set<OWLAnnotation> detailsAnnotations = i.getAnnotations( o, o.getOWLOntologyManager()
          .getOWLDataFactory().getOWLAnnotationProperty(
              DETAILS.getAnnotationPropertyIRI() ) );
      String details = null;
      int ndetails = detailsAnnotations.size();
      if( ndetails > 0 ) {
        if( ndetails > 1 )
          log
              .info( format(
                  "Result contains multiple details annotations, ignoring all but first (\"%s\")",
                  i.getIRI() ) );
        details = detailsAnnotations.iterator().next().getValue().toString();
      }

      TestRunResult result = null;
      if( types.contains( SYNTAX_TRANSLATION_RUN.getOWLClass() ) ) {
        result = (details == null)
          ? new SyntaxTranslationRun( testCase, resultType, runner )
          : new SyntaxTranslationRun( testCase, resultType, runner, details );
      }
      else if( types.contains( SYNTAX_CONSTRAINT_RUN.getOWLClass() ) ) {
        Set<OWLIndividual> constraints = oValues.get( SYNTAX_CONSTRAINT
            .getOWLObjectProperty() );
        SyntaxConstraint constraint = null;
        if( constraints.size() != 1 ) {
          log
              .warning( format(
                  "Skipping result, missing or more than one syntax constraint assertion (\"%s\",%s)",
                  i.getIRI(), constraints ) );
          continue;
        }
        OWLNamedIndividual ind = constraints.iterator().next().asOWLNamedIndividual();
        for( SyntaxConstraint c : SyntaxConstraint.values() ) {
          if( c.getOWLIndividual().equals( ind ) ) {
            constraint = c;
            break;
          }
View Full Code Here


    if( statuses == null || statuses.isEmpty() )
      status = null;
    else if( statuses.size() > 1 )
      throw new IllegalArgumentException();
    else {
      OWLNamedIndividual s = statuses.iterator().next().asOWLNamedIndividual();
      status = Status.get( s );
      if( status == null )
        throw new NullPointerException( format(
            "Unexpected status ( %s ) for test case %s", s.getIRI().toURI().toASCIIString(), i
                .getIRI() ) );
    }

    satisfied = EnumSet.noneOf( SyntaxConstraint.class );
    Set<OWLIndividual> profiles = opValues.get( PROFILE.getOWLObjectProperty() );
    if( profiles != null ) {
      for( OWLIndividual p : profiles ) {
        SyntaxConstraint c = SyntaxConstraint.get( p );
        if( c == null )
          throw new NullPointerException( format(
              "Unexpected profile ( %s ) for test case %s", p.asOWLNamedIndividual().getIRI()
                  .toURI().toASCIIString(), i.getIRI() ) );
        satisfied.add( c );
      }
    }

    Set<OWLIndividual> species = opValues.get( SPECIES.getOWLObjectProperty() );
    if( species != null ) {
      for( OWLIndividual s : species ) {
        if( FULL.getOWLIndividual().equals( s ) )
          continue;
        if( Individual.DL.getOWLIndividual().equals( s ) )
          satisfied.add( SyntaxConstraint.DL );
        else
          throw new IllegalArgumentException( format(
              "Unexpected species ( %s ) for test case %s", s.asOWLNamedIndividual().getIRI()
                  .toURI().toASCIIString(), i.getIRI() ) );
      }
    }

    semantics = EnumSet.noneOf( Semantics.class );
    Set<OWLIndividual> sems = opValues.get( SEMANTICS.getOWLObjectProperty() );
    if( sems != null ) {
      for( OWLIndividual sem : sems ) {
        Semantics s = Semantics.get( sem );
        if( s == null )
          throw new NullPointerException( format(
              "Unexpected semantics ( %s ) for test case %s ", sem.asOWLNamedIndividual().getIRI()
                  .toURI().toASCIIString(), i.getIRI() ) );
        semantics.add( s );
      }
    }

    Map<OWLObjectPropertyExpression, Set<OWLIndividual>> nopValues = i
        .getNegativeObjectPropertyValues( ontology );

    notsatisfied = EnumSet.noneOf( SyntaxConstraint.class );

    Set<OWLIndividual> notprofiles = nopValues.get( PROFILE.getOWLObjectProperty() );
    if( notprofiles != null ) {
      for( OWLIndividual p : notprofiles ) {
        SyntaxConstraint c = SyntaxConstraint.get( p );
        if( c == null )
          throw new NullPointerException( format(
              "Unexpected profile ( %s ) for test case %s", p.asOWLNamedIndividual().getIRI()
                  .toURI().toASCIIString(), i.getIRI() ) );
        notsatisfied.add( c );
      }
    }

    Set<OWLIndividual> notspecies = nopValues.get( SPECIES.getOWLObjectProperty() );
    if( notspecies != null ) {
      for( OWLIndividual s : notspecies ) {
        if( Individual.DL.getOWLIndividual().equals( s ) )
          notsatisfied.add( SyntaxConstraint.DL );
        else
          throw new IllegalArgumentException( format(
              "Unexpected species ( %s ) for test case %s", s.asOWLNamedIndividual().getIRI()
                  .toURI().toASCIIString(), i.getIRI() ) );
      }
    }

    notsemantics = EnumSet.noneOf( Semantics.class );
View Full Code Here

   
    // get all instances of Person class
    NodeSet<OWLNamedIndividual> individuals = reasoner.getInstances( Person, false);
    for(Node<OWLNamedIndividual> sameInd : individuals) {
      // sameInd contains information about the individual (and all other individuals that were inferred to be the same)
      OWLNamedIndividual ind =  sameInd.getRepresentativeElement();
     
        // get the info about this specific individual
      Set<OWLLiteral> names = reasoner.getDataPropertyValues( ind, foafName );                       
        NodeSet<OWLClass> types = reasoner.getTypes( ind, true );       
        NodeSet<OWLNamedIndividual> homepages = reasoner.getObjectPropertyValues( ind, workHomepage );
View Full Code Here

    long e = System.currentTimeMillis();
    System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );

    // peform ABox addition which results in a consistent KB
    OWLClass concept = factory.getOWLClass( IRI.create( mindswap + "GraduateStudent" ) );
    OWLNamedIndividual individual = factory
        .getOWLNamedIndividual( IRI.create( mindswappers + "JohnDoe" ) );
    manager.applyChange( new AddAxiom( ontology, factory.getOWLClassAssertionAxiom( concept, individual ) ) );

    // perform incremental consistency check
    s = System.currentTimeMillis();
    consistent = reasoner.isConsistent();
    e = System.currentTimeMillis();
    System.out.println( "Consistent? " + consistent + " (" + (e - s) + "ms)" );

    // peform ABox addition which results in an inconsistent KB
    OWLObjectProperty role = factory.getOWLObjectProperty( IRI.create( foaf + "mbox" ) );
    individual = factory.getOWLNamedIndividual( IRI.create( mindswappers + "Christian.Halaschek" ) );
    OWLNamedIndividual mbox = factory.getOWLNamedIndividual( IRI.create( "mailto:kolovski@cs.umd.edu" ) );
    manager.applyChange( new AddAxiom( ontology, factory.getOWLObjectPropertyAssertionAxiom(
        role, individual, mbox ) ) );

    // perform incremental consistency check
    s = System.currentTimeMillis();
View Full Code Here

    if( instances.size() > 0 ) {
      out.print( " - (" );
      boolean printed = false;
      Iterator<OWLNamedIndividual> ins = instances.iterator();
      for( int k = 0; ins.hasNext(); k++ ) {
        OWLNamedIndividual x = ins.next();

        if( printed )
          out.print( ", " );
        else
          printed = true;
View Full Code Here

 
  private Set<OWLNamedIndividual> toOWLNamedIndividuals( Set<ATermAppl> terms, OWLDataFactory factory ) {
    HashSet<OWLNamedIndividual> result = new HashSet<OWLNamedIndividual>();
   
    for( ATermAppl ind : terms ) {
      OWLNamedIndividual owlInd = termToOWLNamedIndividual( ind, factory );     
      if( owlInd != null ) {
        result.add( owlInd );
      }
    }
   
View Full Code Here

   
    try {
          // force classification
          classifier.classify();
          // force realization
          OWLNamedIndividual ind1 = Individual(ns + "ind1");
          classifier.getTypes(ind1, true);
          testOWL2Reasoner(ns, classifier);
        }
        finally {
          classifier.dispose();
View Full Code Here

    OWLClass OlderThan10 = Class( ns + "OlderThan10" );
    OWLClass YoungerThan20 = Class( ns + "YoungerThan20" );
    OWLClass Teenager = Class( ns + "Teenager" );
    OWLClass Teen = Class( ns + "Teen" );

    OWLNamedIndividual ind1 = Individual( ns + "ind1" );
    OWLNamedIndividual ind3 = Individual( ns + "ind3" );
    OWLNamedIndividual ind4 = Individual( ns + "ind4" );
    OWLNamedIndividual ind5 = Individual( ns + "ind5" );
    OWLNamedIndividual ind6 = Individual( ns + "ind6" );

    OWLObjectProperty p = ObjectProperty( ns + "p" );
    OWLObjectProperty r = ObjectProperty( ns + "r" );
    OWLObjectProperty invR = ObjectProperty( ns + "invR" );
    OWLObjectProperty ir = ObjectProperty( ns + "ir" );
View Full Code Here

    OWLOntology ont = loadOntology( base + "uncle.owl" );

    PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner( ont );

    OWLNamedIndividual Bob = Individual( ns + "Bob" );
    OWLNamedIndividual Sam = Individual( ns + "Sam" );

    OWLObjectProperty uncleOf = ObjectProperty( ns + "uncleOf" );

    assertPropertyValues( reasoner, Bob, uncleOf, Sam );
  }
View Full Code Here

    OWLOntology ont = loadOntology( base + "sibling.owl" );

    PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner( ont );

    OWLNamedIndividual Bob = Individual( ns + "Bob" );
    OWLNamedIndividual John = Individual( ns + "John" );
    OWLNamedIndividual Jane = Individual( ns + "Jane" );

    OWLObjectProperty hasBrother = ObjectProperty( ns + "hasBrother" );
    OWLObjectProperty hasSister = ObjectProperty( ns + "hasSister" );

    assertPropertyValues( reasoner, Bob, hasBrother, John );
View Full Code Here

TOP

Related Classes of org.semanticweb.owlapi.model.OWLNamedIndividual

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.