Class StringTools
java.lang.Object
org.episteme.social.linguistics.loaders.tigerxml.tools.StringTools
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic final StringcleanXMLString(String dirtyXMLString) Cleans an XML String by translating special characters into XML entity references.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.static final voidstatic final intminEditDistance(String strA, String strB) Computes the Minumum Edit Distance between twoStringobjects.string2ArrayList(String str) Returns anArrayListconsisting of the single characters (char) of the argumentstr.static voidwriteStringToFile(String str, String fileName) Writes a givenStringto a file.
-
Constructor Details
-
StringTools
public StringTools()
-
-
Method Details
-
cleanXMLString
Cleans an XML String by translating special characters into XML entity references. E.g. 'invalid input: '&'', 'invalid input: '<'', 'invalid input: '>'' 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
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
bytesin bytes, KBs, MBs, GBs, or TBs.
-
string2ArrayList
Returns anArrayListconsisting of the single characters (char) of the argumentstr. Each character is packed into aStringobject.- Parameters:
str- TheStringto be expanded.- Returns:
- An
ArrayListofStringobjects - oneStringobject for each character (char) of the argumentstr.
-
minEditDistance
Computes the Minumum Edit Distance between twoStringobjects. The returned integer is the number of operations (substitution, deletion or insertion) necessary to transform oneStringto 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 firstString.strB- The secondString.- Returns:
- The minimum number of operations to transform
strAintostrB.
-
writeStringToFile
-
main
-