Package com.clarkparsia.pellet.sparqldl.model

Examples of com.clarkparsia.pellet.sparqldl.model.QueryAtom


    int n = atoms.size();
   
    Set<ATermAppl> lastBound = new HashSet<ATermAppl>( bound );
    List<Set<ATermAppl>> boundList = new ArrayList<Set<ATermAppl>>(n);
    for( int i = 0; i < n; i++ ) {
      QueryAtom atom = atoms.get( i );
     
      boundList.add( lastBound );
     
      lastBound = new HashSet<ATermAppl>( lastBound );
      lastBound.addAll( atom.getArguments() )
    }
   
   
    for( int i = n - 1; i >= 0; i-- ) {
      QueryAtom atom = atoms.get( i );

      estimate( atom, boundList.get( i ) );

      totalBranchCount *= branchCount;
      totalStaticCount = staticCost + branchCount * totalStaticCount;
 
View Full Code Here


      return minCost;
    }

    LOOP: for( int i = 0; i < atoms.size(); i++ ) {
      QueryAtom atom = atoms.get( i );

      boolean newNonOptimal = notOptimal;
      Set<ATermAppl> newBoundVars = new HashSet<ATermAppl>( boundVars );
      // TODO reorder UV atoms after all class and property variables are
      // bound.

      if( !atom.isGround() ) {
        int boundCount = 0;
        int unboundCount = 0;

        for( ATermAppl a : atom.getArguments() ) {
          if( ATermUtils.isVar( a ) ) {
            if( newBoundVars.add( a ) ) {
              unboundCount++;

              /*
               * It is not valid to have an ordering like
               * NotKnown(ClassAtom(?x, A)), ClassAtom(?x, B).
               * This is because variables in negation atom will
               * not be bound by the query evaluation. However, if
               * an atom in the query later binds the variable to
               * a value the result will be incorrect because
               * earlier evaluation of negation was not evaluated
               * with that binding.
               */
              if( atom.getPredicate().equals( QueryPredicate.NotKnown ) ) {
                for( int j = 0; j < atoms.size(); j++ ) {
                  QueryAtom nextAtom = atoms.get( j );
                 
                  if( i == j
                    || nextAtom.getPredicate().equals(
                          QueryPredicate.NotKnown ) ) {
                    continue;
                  }

                  if( nextAtom.getArguments().contains( a ) ) {
                    if( log.isLoggable( Level.FINE ) )
                      log.fine( "Unbound vars for not" );
                    continue LOOP;
                  }
                }
View Full Code Here

  }

  @Override
  public QueryAtom next(final ResultBinding binding) {
    int best = -1;
    QueryAtom bestAtom = null;
    double bestCost = Double.POSITIVE_INFINITY;

    LOOP: for( int i = 0; i < size; i++ ) {
      if( !explored.contains( i ) ) {
        QueryAtom atom = atoms.get( i );
        QueryAtom atom2 = atom.apply( binding );

       
        if( atom2.getPredicate().equals( QueryPredicate.NotKnown ) && !atom2.isGround() ) {
          for( int j = 0; j < atoms.size(); j++ ) {
            if( i == j || explored.contains( j ) ) {
              continue;
            }

            QueryAtom nextAtom = atoms.get( j );
            if( SetUtils.intersects( nextAtom.getArguments(), atom2.getArguments() ) ) {
              if( log.isLoggable( Level.FINE ) )
                log.fine( "Unbound vars for not" );
              continue LOOP;
            }
          }
View Full Code Here

    public static QueryResult getSubsumptionMappings( Query sub, Query sup) {
        KnowledgeBase kb = sup.getKB().copy( true );
       
        List<QueryAtom> queryAtoms = sub.getAtoms();
        for( Iterator<QueryAtom> i = queryAtoms.iterator(); i.hasNext(); ) {
            final QueryAtom queryAtom = (QueryAtom) i.next();
            final List<ATermAppl> arguments = queryAtom.getArguments();
           
            ATermAppl ind1 = null;
            ATermAppl ind2 = null;
            ATermAppl pr = null;
            ATermAppl cl = null;
           
            switch(queryAtom.getPredicate()){
              case Type:
                ind1 = TermFactory.term(arguments.get(0).toString());
                cl = arguments.get(1);
                kb.addIndividual(ind1);
                kb.addType(ind1, cl);
                break;
              case PropertyValue:
                ind1 = TermFactory.term(arguments.get(0).toString());
                pr = arguments.get(1);
                ind2 = TermFactory.term(arguments.get(2).toString());
                kb.addIndividual(ind1);
                kb.addIndividual(ind2);
                kb.addPropertyValue(pr, ind1, ind2);
                break;
              case SameAs:
                ind1 = TermFactory.term(arguments.get(0).toString());
                ind2 = TermFactory.term(arguments.get(1).toString());
                kb.addIndividual(ind1);
                kb.addIndividual(ind2);
                kb.addSame(ind1, ind2);
                break;
              case DifferentFrom:
                ind1 = TermFactory.term(arguments.get(0).toString());
                ind2 = TermFactory.term(arguments.get(1).toString());
                kb.addIndividual(ind1);
                kb.addIndividual(ind2);
                kb.addDifferent(ind1, ind2);
                break;
              default:
              throw new UnsupportedQueryException( "Unsupported atom type : " + queryAtom.getPredicate().toString() );
            }             
        }
       
        kb.isConsistent();
       
View Full Code Here

        log.finer( "Returning ... binding=" + binding );
      }
      return;
    }

    final QueryAtom current = plan.next( binding );
   
    if( log.isLoggable( Level.FINER ) ) {
      log.finer( "Evaluating " + current );
    }
   
    if( current.isGround() && !current.getPredicate().equals( QueryPredicate.UndistVarCore ) ) {
      if( QueryEngine.checkGround( current, kb ) ) {
        exec( binding );
      }
    }
    else {
View Full Code Here

TOP

Related Classes of com.clarkparsia.pellet.sparqldl.model.QueryAtom

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.