<commit_before>package leo.modules

import leo.datastructures.{Kind, Type, Signature}

/**
  * Collection of traits, clases and utility objects relevant for
  * primarily for logging and output of TPTP problems.
  */
package object output {
  ///////////////////////////////
  // Naming of variables
  ///////////////////////////////

  @inline final private val asciiA = 65
  @inline final private val asciiZ = 90
  @inline final private val range = asciiZ - asciiA // range 0,1,....

  /**
    * Convert index i (variable in de-bruijn format) to a variable name corresponding to ASCII transformation as follows:
    * 0 ---> "A",
    * 1 ---> "B",
    * 25 ---> "Z",
    * 26 ---> "ZA", ... etc.
    */
  protected[output] final def intToName(i: Int): String = i match {
    case n if n <= range => s"${intToChar(i)}"
    case n if n > range => s"Z${intToName(i-range-1)}"
  }
  protected[output] final def intToChar(i: Int): Char = i match {
    case n if n <= range => (n + asciiA).toChar
    case _ => throw new IllegalArgumentException
  }

  private final val simpleNameRegex = "^[a-z]([a-zA-Z\\d]*)$"
  final def tptpEscapeName(str: String): String = {
    if (str.matches(simpleNameRegex)) str
    else s"'${str.replace("\\","\\\\").replace("'", "\\'")}'"
  }
  private final val simpleExpressionRegex = "^([a-z]|\\${1,2}[a-z])([a-zA-Z\\d]*)$"
  final def tptpEscapeExpression(str: String): String = {
    if (str.matches(simpleExpressionRegex)) str
    else s"'${str.replace("\\","\\\\").replace("'", "\\'")}'"
  }

  /**
    * For a sequence `fvs` of free vars (implicitly universally quantified) and a function
    * `typeToTPTP`, return a tuple `(rep,map)` where<commit_msg>tptp atomicword allows also underscores<commit_after>package leo.modules

import leo.datastructures.{Kind, Type, Signature}

/**
  * Collection of traits, clases and utility objects relevant for
  * primarily for logging and output of TPTP problems.
  */
package object output {
  ///////////////////////////////
  // Naming of variables
  ///////////////////////////////

  @inline final private val asciiA = 65
  @inline final private val asciiZ = 90
  @inline final private val range = asciiZ - asciiA // range 0,1,....

  /**
    * Convert index i (variable in de-bruijn format) to a variable name corresponding to ASCII transformation as follows:
    * 0 ---> "A",
    * 1 ---> "B",
    * 25 ---> "Z",
    * 26 ---> "ZA", ... etc.
    */
  protected[output] final def intToName(i: Int): String = i match {
    case n if n <= range => s"${intToChar(i)}"
    case n if n > range => s"Z${intToName(i-range-1)}"
  }
  protected[output] final def intToChar(i: Int): Char = i match {
    case n if n <= range => (n + asciiA).toChar
    case _ => throw new IllegalArgumentException
  }

  private final val simpleNameRegex = "^[a-z]([a-zA-Z\\d_]*)$"
  final def tptpEscapeName(str: String): String = {
    if (str.matches(simpleNameRegex)) str
    else s"'${str.replace("\\","\\\\").replace("'", "\\'")}'"
  }
  private final val simpleExpressionRegex = "^([a-z]|\\${1,2}[a-z])([a-zA-Z\\d_]*)$"
  final def tptpEscapeExpression(str: String): String = {
    if (str.matches(simpleExpressionRegex)) str
    else s"'${str.replace("\\","\\\\").replace("'", "\\'")}'"
  }

  /**
    * For a sequence `fvs` of free vars (implicitly universally quantified) and a function
    * `typeToTPTP`, return a tuple `(rep,map)` where
{'fraction_non_alphanumeric': 0.20517342739564962, 'fraction_numerical': 0.008818342151675485, 'mean_word_length': 2.6552094522019334, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1362621', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1096, 'n_words': 331}