Class Statistics

java.lang.Object
org.omegat.core.statistics.Statistics

public final class Statistics extends Object
Save project statistic into text file.
  • Method Details

    • numberOfCharactersWithoutSpaces

      public static int numberOfCharactersWithoutSpaces(String str)
      Computes the number of characters excluding spaces in a string. Special char for tag replacement not calculated.
    • numberOfCharactersWithSpaces

      public static int numberOfCharactersWithSpaces(String str)
      Computes the number of characters with spaces in a string. Special char for tag replacement not calculated.
    • numberOfWords

      public static int numberOfWords(String str)
      Computes the number of words in a string.
    • writeStat

      public static void writeStat(String filename, String text)
      Writes the specified text to a file, along with the current date and time. If the target file's parent directories do not exist, they will be created. Any existing content in the file will be overwritten.
      Parameters:
      filename - the name and path of the file to which the text will be written
      text - the text content to write to the file
    • writeStat

      public static void writeStat(String dir, StatsResult result)
      Writes the statistics result to the specified directory in all selected output formats.
      Parameters:
      dir - the directory where the statistics should be written
      result - the statistics result object containing the data to be written
    • writeStat

      public static void writeStat(String dir, StatsResult result, StatOutputFormat format)
      Writes the statistics result to the specified directory in the given output format. Depending on the format, the data is written as text, XML, or JSON. The file is encoded in UTF-8. If any errors occur during file writing, they are logged.
      Parameters:
      dir - the directory where the statistics file should be written
      result - the statistics result object containing the data to be written
      format - the format in which the statistics should be written (TEXT, XML, or JSON)
    • getUniquenessKey

      public static String getUniquenessKey(SourceTextEntry ste)
      Get unique key for segment for uniqueness calculation.
    • buildProjectStats

      public static StatsResult buildProjectStats(IProject project)
      Builds a file with statistic info about the project. The total word & character count of the project, the total number of unique segments, plus the details for each file.