Class LanguageFormatter

java.lang.Object
com.articulate.sigma.nlg.LanguageFormatter

public class LanguageFormatter extends Object
A class that handles the generation of natural language from logic.
Author:
Adam Pease - apease [at] articulatesoftware [dot] com, with thanks to Michal Sevcenko - sevcenko@vc.cvut.cz for development of the formatting language.
  • Field Details

    • debug

      public static boolean debug
    • outputMap

      public static Map<String,edu.stanford.nlp.ling.CoreLabel> outputMap
    • tptpStep

      public static tptp_parser.TPTPFormula tptpStep
    • paraphraseLLM

      public static boolean paraphraseLLM
  • Constructor Details

    • LanguageFormatter

      public LanguageFormatter(String stmt, Map<String,String> phraseMap, Map<String,String> termMap, KB kb, String language)
      Parameters:
      stmt - The statement to be formatted.
      phraseMap - kb.getFormatMap() for this language
      termMap - kb.getTermFormatMap() for this language
      kb -
      language -
  • Method Details

    • setDoInformalNLG

      public void setDoInformalNLG(boolean doIt)
    • htmlParaphrase

      public String htmlParaphrase(String href)
      Hyperlink terms in a natural language format string. This assumes that terms to be hyperlinked are in the form invalid input: '&'%termName$termString , where termName is the name of the term to be browsed in the knowledge base and termString is the text that should be displayed hyperlinked.
      Parameters:
      href - the anchor string up to the term= parameter, which this method will fill in.
      Returns:
    • paraphraseStatement

      public String paraphraseStatement(String stmt, boolean isNegMode, boolean isQuestionMode, int depth)
      Create a natural language paraphrase of a logical statement.
      Parameters:
      stmt - The statement to be paraphrased.
      isNegMode - Whether the statement is negated.
      depth - An int indicating the level of nesting, for control of indentation.
      Returns:
      A String, which is the paraphrased statement.
    • checkOllamaHealth

      public static boolean checkOllamaHealth()
    • generateProofSummary

      public static String generateProofSummary(List<String> proofSteps)
      Generate a natural language summary of a proof using Ollama LLM
      Parameters:
      proofSteps - List of proof steps as strings
      Returns:
      HTML formatted proof summary
    • generateFormalNaturalLanguage

      public String generateFormalNaturalLanguage(List<String> args, String pred, boolean isNegMode)
    • generateFormalNaturalLanguage

      public String generateFormalNaturalLanguage(List<String> args, String pred, boolean isNegMode, com.articulate.sigma.nlg.LanguageFormatter.RenderMode mode)
    • translateWord

      public static String translateWord(Map<String,String> termMap, String word)
      Return the NL format of an individual word.
    • removePreamble

      public static String removePreamble(String input)
      Remove the type declarations from the text
    • variableReplace

      public static String variableReplace(String form, Map<String,Set<String>> instMap, Map<String,Set<String>> classMap, KB kb, String language)
      Replace variables in a formula with paraphrases expressing their type.
    • test1

      public static void test1()
    • test2

      public static void test2()
    • test3

      public static void test3()
    • test4

      public static void test4()
    • setKB

      public static void setKB(KB kbin)
    • toEnglish

      public static String toEnglish(String form)
      generate English paraphrase
    • showHelp

      public static void showHelp()
    • main

      public static void main(String[] args)
      A test method.