public class Thesaurus extends Object implements Serializable
Modifier and Type | Field and Description |
---|---|
static LinkedHashMap<String,ArrayList<String>> |
categories |
static LinkedHashMap<String,ArrayList<String>> |
languages |
LinkedHashMap<String,GapShuffler<String>> |
mappings |
protected StatefulRNG |
rng |
protected static regexodus.Pattern |
wordMatch |
Constructor and Description |
---|
Thesaurus()
Constructs a new Thesaurus with an unseeded RNG used to shuffle word order.
|
Thesaurus(long shuffleSeed)
Constructs a new Thesaurus, seeding its RNG (used to shuffle word order) with shuffleSeed.
|
Thesaurus(RNG rng)
Constructs a new Thesaurus, seeding its RNG (used to shuffle word order) with the next long from the given RNG.
|
Thesaurus(String shuffleSeed)
Constructs a new Thesaurus, seeding its RNG (used to shuffle word order) with shuffleSeed.
|
Modifier and Type | Method and Description |
---|---|
Thesaurus |
addCategory(String keyword,
Collection<String> synonyms)
Allows this Thesaurus to replace a specific keyword, typically containing multiple backtick characters ('`') so
it can't be confused with a "real word," with one of the words in synonyms (chosen in shuffled order).
|
Thesaurus |
addFakeWords()
Adds a large list of words pre-generated by FakeLanguageGen and hand-picked for fitness, and makes them
accessible with a keyword based on the language and any tweaks made to it.
|
Thesaurus |
addKnownCategories()
Adds several pre-made categories to this Thesaurus' known categories, but won't cause it to try to replace normal
words with synonyms (only categories, which contain backticks in the name).
|
Thesaurus |
addSynonyms(Collection<String> synonyms)
Allows this Thesaurus to find the exact words in synonyms and, when requested, replace each occurrence with a
different word from the same Collection.
|
String |
lookup(String word) |
String |
process(CharSequence text)
Given a String, StringBuilder, or other CharSequence that should contain words this knows synonyms for, this
replaces each occurrence of such a known word with one of its synonyms, leaving unknown words untouched.
|
protected static final regexodus.Pattern wordMatch
public LinkedHashMap<String,GapShuffler<String>> mappings
protected StatefulRNG rng
public static LinkedHashMap<String,ArrayList<String>> categories
public static LinkedHashMap<String,ArrayList<String>> languages
public Thesaurus()
public Thesaurus(RNG rng)
rng
- an RNG that will only be used to get one long (for seeding this class' RNG)public Thesaurus(long shuffleSeed)
shuffleSeed
- a long for seeding this class' RNGpublic Thesaurus addSynonyms(Collection<String> synonyms)
synonyms
- a Collection of lower-case Strings with similar meaning and the same part of speechpublic Thesaurus addCategory(String keyword, Collection<String> synonyms)
keyword
- a word (typically containing backticks, '`') that will be replaced by a word from synonymssynonyms
- a Collection of lower-case Strings with similar meaning and the same part of speechpublic Thesaurus addKnownCategories()
public Thesaurus addFakeWords()
public String process(CharSequence text)
text
- a CharSequence, such as a String, that contains words in the source languageCopyright © 2012–2016. All rights reserved.