Package squidpony
Class FakeLanguageGen.SentenceForm
java.lang.Object
squidpony.FakeLanguageGen.SentenceForm
- All Implemented Interfaces:
Serializable
- Enclosing class:
- FakeLanguageGen
public static class FakeLanguageGen.SentenceForm extends Object implements Serializable
A simple way to bundle a FakeLanguageGen with the arguments that would be passed to it when calling
FakeLanguageGen.sentence(IRNG, int, int, String[], String[], double, int)
or one of its overloads.
You can call sentence()
on this to produce another String sentence with the parameters it was given
at construction. The parameters to
SentenceForm(FakeLanguageGen, IStatefulRNG, int, int, String[], String[], double, int)
are stored in fields of
the same name, and all fields in this class are public and modifiable.- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description String[]
endPunctuation
FakeLanguageGen
language
int
maxChars
int
maxWords
String[]
midPunctuation
double
midPunctuationFrequency
int
minWords
IStatefulRNG
rng
-
Constructor Summary
Constructors Constructor Description SentenceForm()
Builds a SentenceForm with all default fields, usingFakeLanguageGen.FANTASY_NAME
for a language, using between 1 and 9 words in a sentence, and otherwise defaulting to howSentenceForm(FakeLanguageGen, int, int)
behaves.SentenceForm(FakeLanguageGen language, int minWords, int maxWords)
Builds a SentenceForm with only a few fields specified.SentenceForm(FakeLanguageGen language, int minWords, int maxWords, String[] midPunctuation, String[] endPunctuation, double midPunctuationFrequency)
Builds a SentenceForm with all fields specified except forrng
, which will be made based on FakeLanguageGen's staticFakeLanguageGen.srng
field, and maxChars, which means the sentence length will be limited only by maxWords and the length of words produced.SentenceForm(FakeLanguageGen language, int minWords, int maxWords, String[] midPunctuation, String[] endPunctuation, double midPunctuationFrequency, int maxChars)
Builds a SentenceForm with all fields specified except forrng
, which will be made based on FakeLanguageGen's staticFakeLanguageGen.srng
field.SentenceForm(FakeLanguageGen language, IStatefulRNG rng, int minWords, int maxWords, String[] midPunctuation, String[] endPunctuation, double midPunctuationFrequency, int maxChars)
Builds a SentenceForm with all fields specified; each value is referenced directly except forrng
, which will not change or be directly referenced (a new GWTRNG will be used with the same state value). -
Method Summary
Modifier and Type Method Description static FakeLanguageGen.SentenceForm
deserializeFromString(String ser)
String
sentence()
String
serializeToString()
-
Field Details
-
Constructor Details
-
SentenceForm
public SentenceForm()Builds a SentenceForm with all default fields, usingFakeLanguageGen.FANTASY_NAME
for a language, using between 1 and 9 words in a sentence, and otherwise defaulting to howSentenceForm(FakeLanguageGen, int, int)
behaves. -
SentenceForm
Builds a SentenceForm with only a few fields specified. Therng
will be made based on FakeLanguageGen's staticFakeLanguageGen.srng
field, maxChars will be -1 so the sentence length will be limited only by maxWords and the length of words produced, and the between-word and end-of-sentence punctuation will be set to reasonable defaults. This places either a comma or a semicolon after a word in the middle of a sentence about 18% of the time (midPunctuationFrequency
is 0.18), and can end a sentence in a period, exclamation mark, question mark, or ellipsis (the "..." punctuation).- Parameters:
language
- A FakeLanguageGen to use to generate wordsminWords
- minimum words per sentencemaxWords
- maximum words per sentence
-
SentenceForm
public SentenceForm(FakeLanguageGen language, int minWords, int maxWords, String[] midPunctuation, String[] endPunctuation, double midPunctuationFrequency)Builds a SentenceForm with all fields specified except forrng
, which will be made based on FakeLanguageGen's staticFakeLanguageGen.srng
field, and maxChars, which means the sentence length will be limited only by maxWords and the length of words produced.- Parameters:
language
- A FakeLanguageGen to use to generate wordsminWords
- minimum words per sentencemaxWords
- maximum words per sentencemidPunctuation
- an array of Strings that can be used immediately after words in the middle of sentences, like "," or ";"endPunctuation
- an array of Strings that can end a sentence, like ".", "?", or "..."midPunctuationFrequency
- the probability that two words will be separated by a String from midPunctuation, between 0.0 and 1.0
-
SentenceForm
public SentenceForm(FakeLanguageGen language, int minWords, int maxWords, String[] midPunctuation, String[] endPunctuation, double midPunctuationFrequency, int maxChars)Builds a SentenceForm with all fields specified except forrng
, which will be made based on FakeLanguageGen's staticFakeLanguageGen.srng
field.- Parameters:
language
- A FakeLanguageGen to use to generate wordsminWords
- minimum words per sentencemaxWords
- maximum words per sentencemidPunctuation
- an array of Strings that can be used immediately after words in the middle of sentences, like "," or ";"endPunctuation
- an array of Strings that can end a sentence, like ".", "?", or "..."midPunctuationFrequency
- the probability that two words will be separated by a String from midPunctuation, between 0.0 and 1.0maxChars
- the maximum number of chars to use in a sentence, or -1 for no hard limit
-
SentenceForm
public SentenceForm(FakeLanguageGen language, IStatefulRNG rng, int minWords, int maxWords, String[] midPunctuation, String[] endPunctuation, double midPunctuationFrequency, int maxChars)Builds a SentenceForm with all fields specified; each value is referenced directly except forrng
, which will not change or be directly referenced (a new GWTRNG will be used with the same state value).- Parameters:
language
- A FakeLanguageGen to use to generate wordsrng
- a StatefulRNG that will not be directly referenced; the state will be copied into a new StatefulRNGminWords
- minimum words per sentencemaxWords
- maximum words per sentencemidPunctuation
- an array of Strings that can be used immediately after words in the middle of sentences, like "," or ";"endPunctuation
- an array of Strings that can end a sentence, like ".", "?", or "..."midPunctuationFrequency
- the probability that two words will be separated by a String from midPunctuation, between 0.0 and 1.0maxChars
- the maximum number of chars to use in a sentence, or -1 for no hard limit
-
-
Method Details