Package ru.bmstu.datalog.data

Examples of ru.bmstu.datalog.data.Argument


   
    while(resultSet.next()) {
      ArrayList<Argument> args = new ArrayList<Argument>();
     
      for (int i = 0; i < predicate.size(); ++i)
        args.add(new Argument(resultSet.getString("f" + i)));
     
      answer.add(new Predicate(predicate.getName(), args));
    }   
   
    return answer;
View Full Code Here


   
    boolean isAndUsed = false;
   
   
    for (int i = 0; i < predicate.size(); ++i) {
      Argument arg = predicate.get(i);
      if (arg.isConstant()) {
        if (isAndUsed)   query.append(" AND ");
        else     isAndUsed = true;
       
        query.append("f");
        query.append(i);
        query.append("=?");
      } else {
        int var = arg.getVariable();
        if (hashVar.containsKey(var)) {
          if (isAndUsed)   query.append(" AND ");
          else     isAndUsed = true;
         
          query.append("f");
View Full Code Here

  private static Predicate getRequest(Predicate predicate) {
    ArrayList<Argument> args = new ArrayList<Argument>();
    HashMap<String, Integer> hash = new HashMap<String, Integer>();
   
    for (Argument arg : predicate.getArgs()) {
      arg = new Argument(arg);

      if (arg.isVariable())  
        evaluateVariable(hash, arg);
      args.add(arg);
    }
View Full Code Here

    substitution = new HashMap<Argument, Argument>();
    addAll(unifier);
  }

  public boolean isEqual(Argument a, Argument b) {
    Argument subA = substitution.get(a);
    Argument subB = substitution.get(b);
    if (subA == null) subA = a;
    if (subB == null) subB = b;
    return subA.equals(subB);
  }
View Full Code Here

    if (subB == null) subB = b;
    return subA.equals(subB);
  }

  public Argument unify(Argument key) {
    Argument value = substitution.get(key);
    if (value != null) return substitution.get(key);
    return key;
  }
View Full Code Here

    Unifier unifier = new Unifier();
    boolean unifies = true;
    int lengthOfPredicate = p1.size();
   
    for (int i = 0; i < lengthOfPredicate && unifies; ++i) {
      Argument p1Arg = p1.get(i);
      Argument p2Arg = p2.get(i);
     
      if (unifier.isEqual(p1Arg, p2Arg) == false) {       
        if (unifier.unify(p1Arg).isVariable()) {
          unifier.addWithUnify(p1Arg, p2Arg);
         
View Full Code Here

   * Term ::= Number | Name | '_'
   * @return {@link Argument}
   * @throws Exception
   */
  private static Argument parseTerm() throws Exception {
    Argument answer;
   
    int cur = currentSymbol;
    try {
      answer = new Argument(parseNumber());
     
    } catch(Exception e) {
      currentSymbol = cur;
     
      if (curSymbol() == '_') {
        answer = new Argument("_", -1);
        next();
      } else {
        boolean isConstant = Character.isLowerCase(curSymbol());
        if (isConstant) {
          answer = new Argument(parseName());
        } else {
          answer = new Argument(parseName(), -1);
        }
      }
    }
   
    return answer;
View Full Code Here

TOP

Related Classes of ru.bmstu.datalog.data.Argument

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.