hcrypto.analyzer
Class TextStatistics

java.lang.Object
  |
  +--hcrypto.analyzer.TextStatistics
All Implemented Interfaces:
Analyzer

public class TextStatistics
extends java.lang.Object
implements Analyzer


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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KAPPA_R

public static final double KAPPA_R

KAPPA_P

public static final double KAPPA_P

englishFrequency

public static final double[] englishFrequency

digram_chars

public static final int digram_chars

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