001 package aima.logic.fol.inference; 002 003 import aima.logic.fol.inference.proof.Proof; 004 import aima.logic.fol.inference.proof.ProofPrinter; 005 006 /** 007 * @author Ciaran O'Reilly 008 * 009 */ 010 public class InferenceResultPrinter { 011 /** 012 * Utility method for outputting InferenceResults in a formatted textual 013 * representation. 014 * 015 * @param ir 016 * an InferenceResult 017 * @return a String representation of the InferenceResult. 018 */ 019 public static String printInferenceResult(InferenceResult ir) { 020 StringBuilder sb = new StringBuilder(); 021 022 sb.append("InferenceResult.isTrue=" + ir.isTrue()); 023 sb.append("\n"); 024 sb.append("InferenceResult.isPossiblyFalse=" + ir.isPossiblyFalse()); 025 sb.append("\n"); 026 sb.append("InferenceResult.isUnknownDueToTimeout=" 027 + ir.isUnknownDueToTimeout()); 028 sb.append("\n"); 029 sb.append("InferenceResult.isPartialResultDueToTimeout=" 030 + ir.isPartialResultDueToTimeout()); 031 sb.append("\n"); 032 sb.append("InferenceResult.#Proofs=" + ir.getProofs().size()); 033 sb.append("\n"); 034 int proofNo = 0; 035 for (Proof p : ir.getProofs()) { 036 proofNo++; 037 sb.append("InferenceResult.Proof#" + proofNo + "=\n" 038 + ProofPrinter.printProof(p)); 039 } 040 041 return sb.toString(); 042 } 043 }