Package org.mindswap.pellet

Examples of org.mindswap.pellet.Role


    return true;
  }

  private boolean isAllValuesSafe(KnowledgeBase kb, Individual parent, Role role, ATermAppl term) {
    Role s = kb.getRole( term.getArgument( 0 ) );
    if( !s.hasComplexSubRole() ) {
      ATermAppl c = (ATermAppl) term.getArgument( 1 );

      if( role.isSubRoleOf( s ) && !parent.hasType( c ) )
        return false;
    }
    else {
      TransitionGraph<Role> tg = s.getFSM();

      for( Transition<Role> t : tg.getInitialState().getTransitions() ) {
        if( role.isSubRoleOf( t.getName() ) )
          return false;
      }
View Full Code Here


  private boolean isFunctionalSafe(Role role, CachedNode node) {
    return !role.isFunctional() || getRNeighbors( node, role ).isEmpty();
  }

  private boolean isMaxSafe(KnowledgeBase kb, Role role, ATermAppl term) {
    Role maxR = kb.getRole( term.getArgument( 0 ) );

    return !role.isSubRoleOf( maxR );
  }
View Full Code Here

  private Set<ATermAppl> getRNeighbors(CachedNode node, Role role) {
    Set<ATermAppl> neighbors = new HashSet<ATermAppl>();

    for( Edge edge : node.getOutEdges() ) {
      Role r = edge.getRole();
      if( r.isSubRoleOf( role ) ) {
        neighbors.add( edge.getToName() );
      }
    }

    if( role.isObjectRole() ) {
      role = role.getInverse();
      for( Edge edge : node.getInEdges() ) {
        Role r = edge.getRole();
        if( r.isSubRoleOf( role ) ) {
          neighbors.add( edge.getFromName() );
        }
      }
    }
View Full Code Here

    return false;
  }

  protected boolean interactsWithInversesComplex(KnowledgeBase kb, Role role) {
    for( ATermAppl p : expressivity.getAnonInverses() ) {
      Role anonRole = kb.getRole( p );
      if( anonRole.hasComplexSubRole() && anonRole.getFSM().getAlpahabet().contains( role ) )
        return true;

    }

    return false;
View Full Code Here

  private void ensureTypedProperty( ATermAppl pred ) {
   
    if ( ATermUtils.isVar( pred ) )
      return;
   
    Role r = kb.getRole( pred );
    if ( r == null ) {
      throw new UnsupportedQueryException( "Unknown role: " + pred );
    }
   
    if ( r.isUntypedRole() ) {
      throw new UnsupportedQueryException( "Untyped role: " + pred );
    }
  }
View Full Code Here

        final ATermAppl testClass = query.rollUpTo( testVar, Collections
            .<ATermAppl> emptySet(), false );

        ATermAppl newUC = ATermUtils.normalize( ATermUtils.makeNot( testClass ) );

        Role topObjectRole = kb.getRole( TOP_OBJECT_PROPERTY );
        boolean added = topObjectRole.addDomain( newUC, DependencySet.INDEPENDENT );
       
        ABox copy = kb.getABox().copy();
        copy.setInitialized( false );
        querySatisfied = !copy.isConsistent();

        if (added)
          topObjectRole.removeDomain( newUC, DependencySet.INDEPENDENT );
      }
    }

    return querySatisfied;
  }
View Full Code Here

  public Role getRole() {
    return role;
  }
 
  protected EdgeDirection edgeMatches(Edge edge) {
    Role edgeRole = edge.getRole();
    boolean isFwd = edgeRole.isSubRoleOf(role);
    boolean isBwd = (role.getInverse() != null && edgeRole.isSubRoleOf(role.getInverse()));
    return isFwd ? isBwd ? EdgeDirection.BOTH : EdgeDirection.FORWARD : isBwd ? EdgeDirection.BACKWARD : null;
  }
View Full Code Here

  protected Iterator<WME> getMatches(Individual s, Role r, Node o) {
    Iterator<WME> i1 = IteratorUtils.emptyIterator();
    Iterator<WME> i2 = IteratorUtils.emptyIterator();
   
    Role invRole = role.getInverse();
    if (s != null) {
      i1 = toWMEs(getEdges(s.getOutEdges(), role, o), EdgeDirection.FORWARD);
      if (invRole != null) {
        i2 = toWMEs(getEdges(s.getInEdges(), invRole, o), EdgeDirection.BACKWARD);
      }
View Full Code Here

   
    private void addPropertyAtom(BinaryAtom<ATermAppl, ? extends AtomObject, ? extends AtomObject> atom) {
      AtomObject s = atom.getArgument1();
      AtomObject o = atom.getArgument2();
     
      Role role = abox.getRole(atom.getPredicate());
      if (s instanceof AtomVariable && o instanceof AtomVariable) {
        if (s.equals(o)) {
          result = new AlphaReflexiveEdgeNode(abox, role);
        }
        else {
View Full Code Here

          }
        }
      }

      for( final ATermAppl p : properties ) {
        Role role = kb.getRBox().getRole( p );

        int knownSize = 0;
       
        if( role.isObjectRole() ) {
          Set<ATermAppl> knowns = new HashSet<ATermAppl>();
          Set<ATermAppl> unknowns = new HashSet<ATermAppl>();
         
          kb.getABox().getObjectPropertyValues( ind, role, knowns, unknowns,
              true );
          knownSize = knowns.size();
        }
        else {
          List<ATermAppl> knowns = kb.getABox().getObviousDataPropertyValues( ind, role, null );
          knownSize = knowns.size();
        }

        if( knownSize > 0 ) {
          if( log.isLoggable( Level.FINER ) )
            log.finer( "Update " + p + " by " + knownSize );
          pairsPP.put( p, size( p ) + knownSize );
          pSubj.put( p, pSubj.get( p ) + 1 );
        }

        if( role.isObjectRole() ) {
          role = role.getInverse();

          Set<ATermAppl> knowns = new HashSet<ATermAppl>();
          Set<ATermAppl> unknowns = new HashSet<ATermAppl>();

          kb.getABox().getObjectPropertyValues( ind, role, knowns, unknowns,
              true );

          if( !knowns.isEmpty() ) {
            pObj.put( p, pObj.get( p ) + 1 );
          }
        }
      }
    }

    if( !computed ) {
      avgClassesPI = average( classesPI.values() );
      avgDirectClassesPI = average( directClassesPI.values() );
    }

    if( !kb.isRealized() ) {
      for( final ATermAppl c : concepts ) {
        int size = instancesPC.get( c );
        // post processing in case of sampling
        if( size == 0 )
          instancesPC.put( c, 1 );
        else
          instancesPC.put( c, (int) (size / PelletOptions.SAMPLING_RATIO) );

        size = directInstancesPC.get( c );

        // postprocessing in case of sampling
        if( size == 0 )
          directInstancesPC.put( c, 1 );
        else
          directInstancesPC.put( c, (int) (size / PelletOptions.SAMPLING_RATIO) );
      }

      final int avgCPI = Double.valueOf( avgClassesPI ).intValue();
      final int avgDCPI = Double.valueOf( avgDirectClassesPI ).intValue();

      for( final ATermAppl i : kb.getIndividuals() ) {
        Integer size = classesPI.get( i );

        if( size == null ) {
          size = avgCPI;
        }

        // postprocessing in case of sampling
        if( size == 0 )
          classesPI.put( i, 1 );
        else
          classesPI.put( i, (int) (size / PelletOptions.SAMPLING_RATIO) );

        size = directClassesPI.get( i );

        if( size == null ) {
          size = avgDCPI;
        }

        // postprocessing in case of sampling
        if( size == 0 )
          directClassesPI.put( i, 1 );
        else
          directClassesPI.put( i, (int) (size / PelletOptions.SAMPLING_RATIO) );
      }
    }

    for( final ATermAppl p : properties ) {
      int size = size( p );
      if( size == 0 )
        pairsPP.put( p, 1 );
      else
        pairsPP.put( p, (int) (size / PelletOptions.SAMPLING_RATIO) );

      Role role = kb.getRBox().getRole( p );
      ATermAppl invP = (role.getInverse() != null)
        ? role.getInverse().getName()
        : null;
      int subjCount = pSubj.get( p );
      if( subjCount == 0 )
        subjCount = 1;
      int objCount = pObj.get( p );
View Full Code Here

TOP

Related Classes of org.mindswap.pellet.Role

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.