hcrypto.analyzer.tool
Class TextUtilities

java.lang.Object
  extended by hcrypto.analyzer.tool.TextUtilities

public final class TextUtilities
extends java.lang.Object


Field Summary
static int EVAL_DICT
           
static int N_SHUFFLES
           
static int SEED_DICT
           
 
Method Summary
static java.lang.String cleanString(java.lang.String s)
          This method removes punctuation and returns a space delimited string.
static int countInCorrectChars(java.lang.String solution, java.lang.String decrypt)
           
static int countTokens(java.lang.String text)
          countTokens() counts the tokens (words) in the text.
static int countWords(Dictionary eval_dict, java.lang.String text)
          countWords() counts the number of words in the text by looking up each token in the current dictionary
static int countWordsForPattern(java.lang.String pattern)
          countWordsForPattern() counts the number of words in the current dictionary that match the pattern
static Dictionary getDictionary()
          This method returns the English frequency of a given character.
static PatternDictionary getPatternDictionary()
           
static PatternDictionary getPatternDictionary(int which)
           
static java.lang.String getUnusedLetters(java.lang.String s)
           
static boolean isAWord(Dictionary dict, java.lang.String word)
           
static void main(java.lang.String[] args)
           
static java.lang.String makePattern(java.lang.String s)
          This method returns a pattern of the string.
static java.lang.String markWords(Dictionary eval_dict, java.lang.String s)
           
static double percentWords(java.lang.String s1, java.lang.String s2)
           
static java.lang.String randomizeSub(java.lang.String inText, Alphabet alph, int[] substitution, int maxChanged)
           
static java.lang.String remove(java.lang.String s, char ch)
          remove() removes all occurrences of the char ch from a string
static java.lang.String removeDuplicates(java.lang.String s)
          removeDuplicates() removes duplicate tokens from a string
static java.lang.String removeNonAlphabetics(java.lang.String s, Alphabet a)
          This method removes all characters not in the alphabet from the string.
static java.lang.String removeWhiteSpace(java.lang.String s)
          This method removes the whitespace from a String.
static void shuffle(int[] arr)
          shuffle() randomly shuffles integers in an array.
static java.lang.String shuffle(java.lang.String s)
          shuffle() randomly shuffles the characters in a String.
static void shuffle(java.lang.StringBuffer sb)
          shuffle() randomly shuffles the characters in a StringBuffer.
static java.lang.String singleSpaces(java.lang.String inText)
           
static void writeCiphertextFiles(java.lang.String sourceFile, java.lang.String outRootName, int minMessSize, int gapMessSize, int maxMessSize, int numEachSize, Alphabet alph)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EVAL_DICT

public static final int EVAL_DICT
See Also:
Constant Field Values

SEED_DICT

public static final int SEED_DICT
See Also:
Constant Field Values

N_SHUFFLES

public static final int N_SHUFFLES
See Also:
Constant Field Values
Method Detail

getDictionary

public static Dictionary getDictionary()
This method returns the English frequency of a given character.


getPatternDictionary

public static PatternDictionary getPatternDictionary()

getPatternDictionary

public static PatternDictionary getPatternDictionary(int which)

isAWord

public static boolean isAWord(Dictionary dict,
                              java.lang.String word)

countTokens

public static int countTokens(java.lang.String text)
countTokens() counts the tokens (words) in the text.

Parameters:
text - -- a space-delimited string

countWordsForPattern

public static int countWordsForPattern(java.lang.String pattern)
countWordsForPattern() counts the number of words in the current dictionary that match the pattern

Parameters:
pattern - -- a string of the form 1231, 1223, etc.

removeDuplicates

public static java.lang.String removeDuplicates(java.lang.String s)
removeDuplicates() removes duplicate tokens from a string


getUnusedLetters

public static java.lang.String getUnusedLetters(java.lang.String s)

countWords

public static int countWords(Dictionary eval_dict,
                             java.lang.String text)
countWords() counts the number of words in the text by looking up each token in the current dictionary


remove

public static java.lang.String remove(java.lang.String s,
                                      char ch)
remove() removes all occurrences of the char ch from a string

Parameters:
s - -- a String
ch - -- the char being removed

shuffle

public static void shuffle(java.lang.StringBuffer sb)
shuffle() randomly shuffles the characters in a StringBuffer.


shuffle

public static java.lang.String shuffle(java.lang.String s)
shuffle() randomly shuffles the characters in a String.


shuffle

public static void shuffle(int[] arr)
shuffle() randomly shuffles integers in an array.

Parameters:
arr-- - an array of ints

removeWhiteSpace

public static java.lang.String removeWhiteSpace(java.lang.String s)
This method removes the whitespace from a String.


cleanString

public static java.lang.String cleanString(java.lang.String s)
This method removes punctuation and returns a space delimited string.


removeNonAlphabetics

public static java.lang.String removeNonAlphabetics(java.lang.String s,
                                                    Alphabet a)
This method removes all characters not in the alphabet from the string.


makePattern

public static java.lang.String makePattern(java.lang.String s)
This method returns a pattern of the string. For example, if the word is "there" the pattern would be 12343. Words longer than 9 letters using UPPERCASE letters. For example, the word "appendectomy" would have the pattern "12234536789A".


percentWords

public static double percentWords(java.lang.String s1,
                                  java.lang.String s2)

markWords

public static java.lang.String markWords(Dictionary eval_dict,
                                         java.lang.String s)

countInCorrectChars

public static int countInCorrectChars(java.lang.String solution,
                                      java.lang.String decrypt)

randomizeSub

public static java.lang.String randomizeSub(java.lang.String inText,
                                            Alphabet alph,
                                            int[] substitution,
                                            int maxChanged)

singleSpaces

public static java.lang.String singleSpaces(java.lang.String inText)

writeCiphertextFiles

public static void writeCiphertextFiles(java.lang.String sourceFile,
                                        java.lang.String outRootName,
                                        int minMessSize,
                                        int gapMessSize,
                                        int maxMessSize,
                                        int numEachSize,
                                        Alphabet alph)

main

public static void main(java.lang.String[] args)