Class Diagnostics

java.lang.Object
com.articulate.sigma.Diagnostics

public class Diagnostics extends Object
A class that finds problems in a knowledge base. It is not meant to be instantiated.
  • Field Details

  • Constructor Details

    • Diagnostics

      public Diagnostics()
  • Method Details

    • termsWithoutRelation

      public static List<String> termsWithoutRelation(KB kb, String rel, int argnum, char letter)
      Return a list of terms (for a given argument position) that do not have a specified relation.
      Parameters:
      kb - the knowledge base
      rel - the relation name
      argnum - the argument position of the term
      letter - the first letter of the term name
    • termsWithoutDoc

      public static List termsWithoutDoc(KB kb)
      Return a list of terms that do not have a documentation string.
    • termsWithMultipleDoc

      public static List<String> termsWithMultipleDoc(KB kb)
      Return a list of terms that have more than one documentation string.
    • termNotBelowEntity

      public static boolean termNotBelowEntity(String term, KB kb)
      Return a list of terms that do not have Entity as a parent term.
    • termsNotBelowEntity

      public static List<String> termsNotBelowEntity(KB kb)
      Return a list of terms that do not have Entity as a parent term.
    • childrenOfDisjointParents

      public static List<String> childrenOfDisjointParents(KB kb)
      Return a list of terms that have parents which are disjoint.
    • membersNotInAnyPartitionClass

      public static List<String> membersNotInAnyPartitionClass(KB kb)
      Returns a list of terms, each of which is an instance of some exhaustively decomposed class but is not an instance of any of the subclasses that constitute the exhaustive decomposition. For example, given (instance E A) and (partition A B C D), then E is included in the list of terms to be returned if E is not a instance of B, C, or D.
    • relationsWithoutFormat

      public static List<String> relationsWithoutFormat(KB kb)
      Find all relational terms that are missing an NLG format expression
    • termWithoutRules

      public static boolean termWithoutRules(KB kb, String term)
      Term does not appear in any implication (rule).
    • termsWithoutRules

      public static List<String> termsWithoutRules(KB kb)
      Find all terms which do not appear in any implication (rule).
    • singleUseVariables

      public static Set<String> singleUseVariables(Formula f)
      Returns:
      a list of variables used only once.
    • unquantInConsequent

      public static Set<String> unquantInConsequent(Formula f)
      Returns:
      a list of variables only in the consequent that are unquantified TODO: if there's an implication in the consequent, test if the interior consequent has a variable not found in the interior antecedent
    • unquantsInConseq

      public static List<Formula> unquantsInConseq(KB kb)
    • existentialInAntecedent

      public static boolean existentialInAntecedent(Formula f)
      Returns:
      true if an existential is found in the antecedent of a rule.
    • quantifierNotInStatement

      public static boolean quantifierNotInStatement(Formula f)
      Returns:
      true if a quantifiers in a quantifier list is not found in the body of the statement.
    • quantifierNotInBody

      public static List<Formula> quantifierNotInBody(KB kb, String fname)
      Find cases where a variable appears in a quantifier list, but not in the body of the quantified expression. For example (exists (?FOO) (bar ?FLOO Shmoo))
      Returns:
      an ArrayList of Formula(s).
    • quantifierNotInBody

      public static List<Formula> quantifierNotInBody(KB kb)
      Find cases where a variable appears in a quantifier list, but not in the body of the quantified expression. For example (exists (?FOO) (bar ?FLOO Shmoo))
      Returns:
      an ArrayList of Formula(s).
    • addToMapList

      public static void addToMapList(Map<String,List<String>> m, String key, String value)
      Add a key to a map and a value to the ArrayList corresponding to the key. Results are a side effect.
    • addToDoubleMapList

      public static void addToDoubleMapList(Map<String,Map<String,List<String>>> m, String key1, String key2, String value)
      Add a key to a map and a key, value to the map corresponding to the key. Results are a side effect.
    • printTermDependency

      public static String printTermDependency(KB kb, String kbHref)
      Show file dependencies. If two files depend on each other, show only the smaller list of dependencies, under the assumption that that is the erroneous set.
    • makeEmptyKB

      public static KB makeEmptyKB(String kbName)
      Make an empty KB for use in Diagnostics.
      Parameters:
      kbName - the name of the empty KB to make
    • kbConsistencyCheck

      public static String kbConsistencyCheck(KB kb)
      Iterating through all formulas, return a proof of an inconsistent or redundant one, if such a thing exists.
    • termDefsByFile

      public static void termDefsByFile(KB kb)
      Make a table of terms and the files in which they are defined
    • termDefsByGivenFile

      public static void termDefsByGivenFile(KB kb, Set<String> files)
      Make a table of terms and the files in which they are defined
    • addLabels

      public static void addLabels(KB kb, Set<String> file)
      Make a table of terms and the files in which they are defined
    • printAllTerms

      public static void printAllTerms(KB kb)
    • termCapDiff

      public static List<String> termCapDiff(KB kb)
      Find all terms that differ only in capitalization
    • diffTerms

      public static void diffTerms(KB kb, String f1, String f2)
      diff the terms in two KBs (small first, then big) and print all the remainder with their filename and termFormats
    • findOrphanVars

      public static HashMap<String,HashSet<String>> findOrphanVars(Formula f)
      Builds a map of variable co-occurrences in a formula
      Parameters:
      f - the formula to analyze
      Returns:
      map from each variable to the set of variables it co-occurs with
    • findDisconnectedGroups

      public static ArrayList<HashSet<String>> findDisconnectedGroups(HashMap<String,HashSet<String>> links)
      Finds all disconnected variable groups in the graph.
      Parameters:
      links - the variable co-occurrence map
      Returns:
      list of disconnected groups, where each group is a set of connected variables
    • countOccurrences

      public static int countOccurrences(String text, String substring)
      Counts how many times a substring appears in a string.
      Parameters:
      text - the string to search in
      substring - the substring to count
      Returns:
      the number of occurrences
    • showHelp

      public static void showHelp()
    • main

      public static void main(String[] args)
      Test method for this class.