hcrypto.analyzer.tool
Class TextStatistics

java.lang.Object
  extended by hcrypto.analyzer.tool.TextStatistics
All Implemented Interfaces:
Analyzer

public class TextStatistics
extends java.lang.Object
implements Analyzer

Defines a SINGLETON object that is designed to compute and store various useful statistics for a give text. The text is represted as a String.


Field Summary
 int alphabeticsCount
           
 int charCount
           
 double coincidenceIndex
           
static int digram_chars
           
static int[][] digram_data
           
static double[] englishFrequency
           
static double KAPPA_P
           
static double KAPPA_R
           
 
Fields inherited from interface hcrypto.analyzer.Analyzer
DECIPHER_LIMIT
 
Constructor Summary
TextStatistics()
           
TextStatistics(java.lang.String text)
           
TextStatistics(java.lang.String text, boolean stripString)
           
 
Method Summary
 void calcStatistics()
           
static double chiSquare(int[] expected, int[] observed)
          Static methods for Computing chi square statistic
 int getCharCount()
          returns the total number of characters in the text
 double getCoincidenceIndex()
           
static double getEnglishFrequency(char ch)
          Static Utility Methods Used by Analyzers
 int getFrequency(char inChar)
          returns the frequency of its char parameter
 java.lang.String getFrequencyReport()
          returns a 2-D table of frequencies
 FrequencyTable getFrequencyTable()
           
static int getIndexOfMinimum(double[] a)
           
 java.lang.String getKHighestFreqChar(int k)
          returns the the kth highest frequency character
 java.lang.String getReport()
           
 void print()
           
static java.lang.String removeDuplicates(java.lang.String s)
           
static java.lang.String removeNonAlphabetics(java.lang.String s, Alphabet a)
          This method removes all characters not in the alphabet from the string.
 void run()
           
 void setup(java.lang.String text)
          Part of Analyzer interface
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KAPPA_R

public static final double KAPPA_R
See Also:
Constant Field Values

KAPPA_P

public static final double KAPPA_P
See Also:
Constant Field Values

englishFrequency

public static final double[] englishFrequency

digram_chars

public static final int digram_chars
See Also:
Constant Field Values

digram_data

public static final int[][] digram_data

charCount

public int charCount

alphabeticsCount

public int alphabeticsCount

coincidenceIndex

public double coincidenceIndex
Constructor Detail

TextStatistics

public TextStatistics()

TextStatistics

public TextStatistics(java.lang.String text)

TextStatistics

public TextStatistics(java.lang.String text,
                      boolean stripString)
Method Detail

getEnglishFrequency

public static double getEnglishFrequency(char ch)
Static Utility Methods Used by Analyzers


chiSquare

public static double chiSquare(int[] expected,
                               int[] observed)
Static methods for Computing chi square statistic


getIndexOfMinimum

public static int getIndexOfMinimum(double[] a)

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.


removeDuplicates

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

setup

public void setup(java.lang.String text)
Part of Analyzer interface

Specified by:
setup in interface Analyzer

run

public void run()
Specified by:
run in interface Analyzer

getReport

public java.lang.String getReport()
Specified by:
getReport in interface Analyzer

print

public void print()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

calcStatistics

public void calcStatistics()

getCoincidenceIndex

public double getCoincidenceIndex()

getFrequencyTable

public FrequencyTable getFrequencyTable()

getCharCount

public int getCharCount()
returns the total number of characters in the text


getFrequency

public int getFrequency(char inChar)
returns the frequency of its char parameter


getKHighestFreqChar

public java.lang.String getKHighestFreqChar(int k)
returns the the kth highest frequency character


getFrequencyReport

public java.lang.String getFrequencyReport()
returns a 2-D table of frequencies