Package jpl

Examples of jpl.Query


  }
  public class ScheduleSketch {
    private final Query schedules;
    public ScheduleSketch (boolean isFixedOrder) {
      long queryTime = -System.currentTimeMillis();
      schedules = new Query(
          (ast.scheduleConstraintStr != null ? ast.scheduleConstraintStr.replace("\"","") + ", \n" : "") +
          "sequenceClassesP(O,P) " + (isFixedOrder ? ", findall(GO, grammarOrder(GO), [O | _])" : ""));
      queryTime += System.currentTimeMillis();
      if (verbose) System.out.println("Loaded query (" + queryTime + "ms)");
      if (verbose) System.out.println("Using fixed (first) ordering of children: " + isFixedOrder);     
View Full Code Here


      long queryTime = -System.currentTimeMillis();
      Sanitizer s = new Sanitizer(true);
      s.allowTokens(_ast);
      s.simpleQuery(queryString);
      schedules =
        new Query(queryString);
      //schedules = new Query("sequenceClasses" + (isFixedOrder ? "Fixed":"") + "(O,P)");
      queryTime += System.currentTimeMillis();
      if (verbose) System.out.println("Loaded query (" + queryTime + "ms)");
      if (verbose) System.out.println("Using fixed (first) ordering of children: " + isFixedOrder);
     
View Full Code Here

public class AGDebugger {
 
  public String getError () {
    String error = "Unsolvable: \n";   
    Query rem = new Query("countSteps(N, Remaining), member([C, [RefName, Attrib, RefNameType]], Remaining)");
    String nSteps = "0";
    while (rem.hasMoreSolutions()) {
      @SuppressWarnings("unchecked")
      Hashtable<Variable, Term> binding = (Hashtable<Variable, Term>) rem.nextSolution();
      nSteps = binding.get("N").toString(); //FIXME do just once
      error += "  Cannot solve for class '" + binding.get("C") + "': " + binding.get("RefName") + "." + binding.get("Attrib") + "\n";
    }
    error += "Exhausted search after " + nSteps + " inorder traversals.";
    return error;   
View Full Code Here

      throw new InvalidGrammarException("Schedule sanitization failed; could not parse Prolog schedule term " + c.toString());
    }
    return res; 
  }
  public String simpleQuery(String qStr) throws InvalidGrammarException {
    Query q = new Query(qStr);
    String ast = recoverQuery(q.goal());
    return ast;
  }
View Full Code Here

 
  public void runGrammar (String resourceDir, String grammarPath) throws FileNotFoundException
    String algorithm = resourceDir + File.separator + "algorithm.pl";
    long loadTime = -System.currentTimeMillis();
    if (!(new Query("consult('" + grammarPath.replace('\\', '/') + "')")).hasSolution()) throw new FileNotFoundException("Could not find prolog grammar");
    if (!(new Query("consult('" + algorithm.replace('\\', '/') + "')")).hasSolution()) throw new FileNotFoundException("Could not find prolog algorithm");   
    loadTime += System.currentTimeMillis();
    if (verbose) System.out.println("Loaded input (" + loadTime + "ms)");
   
    alreadyRan = true;
  }
View Full Code Here

 
  public static boolean testExternalCallAst () {
    Variable N = new Variable("N");
    jpl.Integer One = new jpl.Integer(1);
    jpl.Integer Thirteen = new jpl.Integer(13);
    Query q = new Query(
        new Compound(";", new Term[]{
            new Compound("succ", new Term[] { Thirteen, N}),
            new Compound("succ", new Term[] { One, N})}));
           
    int sum = 0;
    while (q.hasMoreSolutions()) {
      @SuppressWarnings("unchecked")
      Hashtable<Variable, Term> binding = (Hashtable<Variable, Term>) q.nextSolution();
      sum += ((jpl.Integer) binding.get("N")).intValue();
    }   
    return sum == (14 + 2);
  }
View Full Code Here

    }   
    return sum == (14 + 2);
  }
 
  public static boolean testExternalCallString () {
    Query q = new Query("succ(13, N) ; succ(1, N)");
    int sum = 0;
    while (q.hasMoreElements()) {
      @SuppressWarnings("unchecked")
      Hashtable<Variable, Term> binding = (Hashtable<Variable, Term>) q.nextElement();
      sum += ((jpl.Integer) binding.get("N")).intValue();
    }   
    return sum == (14 + 2);
  }
View Full Code Here

TOP

Related Classes of jpl.Query

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.