net.sf.turkey
Class Generator
public class Generator
extends java.lang.Object
The high-level generator interface.
This is the class You use for text generation---it wraps all the
dictionaries and settings. Just a single instance of this class exists
(having more instances of it just does not make sense), You can get it by
calling the getInstance() method.
PARAGRAPHS_MAX
public static final int PARAGRAPHS_MAX
Maximum number of total paragraphs.
PARAGRAPHS_MIN
public static final int PARAGRAPHS_MIN
Minimum number of total paragraphs.
SENTENCES_MAX
public static final int SENTENCES_MAX
Maximum number of sentences in a paragraph.
SENTENCES_MIN
public static final int SENTENCES_MIN
Minimum number of sentences in a paragraph.
currentTable
protected ProbabilityTable currentTable
The table used for text generation.
htmlOutput
protected boolean htmlOutput
Use HTML tags in the generated text?
instance
protected static Generator instance
The instance of Generator class.
paragraphsTotal
protected int paragraphsTotal
The total number of paragraphs.
samples
protected static final String[] samples
The samples used for building the vocabulary.
The parser in the ProbabilityTable class should chew up
pretty much anything, but you can achieve best results
by saving in the format illustrated by default Turkey
samples --- plain text in UTF-8, one word per line,
case does not matter.
There's a simple Perl script in the samples/ directory
that can do the dirty conversion work for you.
I know this sample loading scheme is not an optimal solution, I'll
try to come up with user-installed samples in the next version.
sentencesPerPar
protected int sentencesPerPar
The number of sentences per paragraph.
tables
protected Vector tables
The list of available probability tables.
Generator
protected Generator()
Loads the text samples.
This method is protected, to make sure nobody creates more instances
of this class. If You want to get the Generator instance, use the
getInstance() method.
getDictionaryNames
public Vector getDictionaryNames()
Returns the names of available dictionaries.
getInstance
public static Generator getInstance()
Returns the Generator class instance.
getParagraphsTotal
public int getParagraphsTotal()
getSentencesPerPar
public int getSentencesPerPar()
getText
public String getText()
Returns generated text.
isHTMLOutput
public boolean isHTMLOutput()
selectDictionary
public void selectDictionary(String name)
Selects dictionary by name, falls back to default dictionary
if no dictionary with given name exists.
setHTMLOutput
public void setHTMLOutput(boolean h)
setParagraphsTotal
public void setParagraphsTotal(int p)
Sets the total number of paragraphs in generated text.
The number is kept between PARAGRAPHS_MIN and PARAGRAPHS_MAX.
setSentencesPerPar
public void setSentencesPerPar(int s)
Sets the number of sentences in generated paragraph.
The number is kept between SENTENCES_MIN and SENTENCES_MAX.