All Downloads are FREE. Search and download functionalities are using the official Maven repository.

TPTPWorld.Binding Maven / Gradle / Ivy

Go to download

Sigma knowledge engineering system is an system for developing, viewing and debugging theories in first order logic. It works with Knowledge Interchange Format (KIF) and is optimized for the Suggested Upper Merged Ontology (SUMO) www.ontologyportal.org.

There is a newer version: 2.10
Show newest version
package TPTPWorld;

import java.io.*;
import java.util.*;
import tptp_parser.*;

public class Binding {
  public String variable;
  public String binding;
  public Binding next;

  // for unbinded variables
  public Binding (String variable) {
    this.variable = variable;
    this.binding = null;
    this.next = null;
  }
  // for binded variables
  public Binding (String variable, String binding) {
    this.variable = variable;
    this.binding = binding;
    this.next = null;        
  }

  public Binding addBinding (String bind) {
    this.binding = bind;
    char c = bind.charAt(0);
    boolean upper = Character.isUpperCase(c);
    if (upper) {
      this.next = new Binding(bind);
      return this.next;
    } 
    return null;
  }

  // if next is not null, then binding is not final binding, recurse
  public String getFinalBinding () {
    if (next == null) {
      return binding;
    } 
    return next.getFinalBinding();        
  }

  public static String getBinding (String variable, ArrayList binds) {          
    for (Binding bind : binds) {
      assert bind.binding != null;
      if (variable.equals(bind.variable)) {
        return bind.binding;
      }
      //      System.out.println(bind.variable + " = " + bind.binding);
    }
    System.out.println("\n% ERROR: Variable did not bind properly in AnswerFinder: " + variable);
    //System.exit(0);
    return "";
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy