net.sf.turkey
Class ProbabilityTable
java.lang.Object
net.sf.turkey.ProbabilityTable
public class ProbabilityTable
extends java.lang.Object
Text analyzer and generator.
This class is able to analyze given sample of text and
generate some text based on the sample's characteristics.
The real work gets done in this class.
static int | PREFIX_LENGTH - The prefix length.
|
protected int | avgWordLength - Average word length of the analyzed text.
|
protected String | name - The name of the table.
|
protected Random | rnd - Random seed generator.
|
protected Map | table - Probability table.
|
ProbabilityTable(InputStream in, String n) - Builds the probability table from an input stream.
|
protected void | analyzeString(String s) - Collects character characteristics of a single string.
|
String | dump() - Returns string representation of the probability table.
|
Character | getNext(String prefix) - Returns character that is likely to follow given prefix.
|
String | getSentence() - Generates a sentence.
|
String | getWord() - Generates a word.
|
String | toString()
|
PREFIX_LENGTH
public static final int PREFIX_LENGTH
The prefix length.
Larger values mean better (less random) output, best are values
around 3.
avgWordLength
protected int avgWordLength
Average word length of the analyzed text.
name
protected String name
The name of the table.
rnd
protected Random rnd
Random seed generator.
table
protected Map table
Probability table.
Contains strings and their probable suffixes.
ProbabilityTable
public ProbabilityTable(InputStream in,
String n)
throws IOException
Builds the probability table from an input stream.
analyzeString
protected void analyzeString(String s)
Collects character characteristics of a single string.
dump
public String dump()
Returns string representation of the probability table.
getNext
public Character getNext(String prefix)
throws UnknownPrefix
Returns character that is likely to follow given prefix.
getSentence
public String getSentence()
Generates a sentence.
getWord
public String getWord()
Generates a word.
toString
public String toString()