Class StringTools

java.lang.Object
org.episteme.social.linguistics.loaders.tigerxml.tools.StringTools

public class StringTools extends Object
Provides methods related to Strings. This class is for static use. * $Id: StringTools.java,v 1.2 2007-10-21 17:47:09 virtualcall Exp $
Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Constructor Details

    • StringTools

      public StringTools()
  • Method Details

    • cleanXMLString

      public static final String cleanXMLString(String dirtyXMLString)
      Cleans an XML String by translating special characters into XML entity references. E.g. 'invalid input: '&amp'', 'invalid input: '&lt'', 'invalid input: '&gt'' and '"' by '&', '<', '>' and '"', respectively, and all characters with ASCII code > 127 by the numeric representation.
      Parameters:
      dirtyXMLString - The XML String to be cleaned
      Returns:
      The cleaned XML String
    • formatBytes

      public String formatBytes(int bytes)
      Formats a given integer value interpreted as number of bytes to a String representing the value in bytes, KBs, MBs, GBs, or TBs.
      Parameters:
      bytes - An integer representing a number of bytes.
      Returns:
      A String representing bytes in bytes, KBs, MBs, GBs, or TBs.
    • string2ArrayList

      public static final ArrayList<String> string2ArrayList(String str)
      Returns an ArrayList consisting of the single characters (char) of the argument str. Each character is packed into a String object.
      Parameters:
      str - The String to be expanded.
      Returns:
      An ArrayList of String objects - one String object for each character (char) of the argument str.
    • minEditDistance

      public static final int minEditDistance(String strA, String strB)
      Computes the Minumum Edit Distance between two String objects. The returned integer is the number of operations (substitution, deletion or insertion) necessary to transform one String to the other.

      The Minimum Edit Distance has been used as a measure for similarity between strings. For a detailed description of the algorithm see:

      Robert A. Wagner and Michael J. Fischer. 1974.
      The string-to-string correction problem.
      Journal of the ACM, 21(1):168 173.

      Parameters:
      strA - The first String.
      strB - The second String.
      Returns:
      The minimum number of operations to transform strA into strB.
    • writeStringToFile

      public static void writeStringToFile(String str, String fileName)
      Writes a given String to a file.
      Parameters:
      str - The String to be written.
      fileName - The name of the file to be written.
    • main

      public static final void main(String[] args)