Package squidpony

Class FakeLanguageGen.Modifier

java.lang.Object
squidpony.FakeLanguageGen.Modifier
All Implemented Interfaces:
Serializable
Enclosing class:
FakeLanguageGen

public static class FakeLanguageGen.Modifier
extends Object
implements Serializable
See Also:
Serialized Form
  • Field Details

  • Constructor Details

  • Method Details

    • modify

      public StringBuilder modify​(IRNG rng, StringBuilder sb)
    • charReplacementTable

      public static FakeLanguageGen.Modifier charReplacementTable​(String initial, String change)
      Creates a Modifier that will replace the nth char in initial with the nth char in change. Expects initial and change to be the same length, but will use the lesser length if they are not equal-length. Because of the state of the text at the time modifiers are run, only lower-case letters need to be searched for.
      Parameters:
      initial - a String containing lower-case letters or other symbols to be swapped out of a text
      change - a String containing characters that will replace occurrences of characters in initial
      Returns:
      a Modifier that can be added to a FakeLanguageGen with its addModifiers() method
    • replacementTable

      Creates a Modifier that will replace the nth String key in map with the nth value. Because of the state of the text at the time modifiers are run, only lower-case letters need to be searched for. This overload of replacementTable allows full regex pattern strings as keys and replacement syntax, such as searching for "([aeiou])\\1+" to find repeated occurrences of the same vowel, and "$1" in this example to replace the repeated section with only the first vowel. The ordering of map matters if a later key contains an earlier key (the earlier one will be replaced first, possibly making the later key not match), or if an earlier replacement causes a later one to become valid.
      Parameters:
      map - containing String keys to replace and String values to use instead; replacements happen in order
      Returns:
      a Modifier that can be added to a FakeLanguageGen with its addModifiers() method
    • replacementTable

      public static FakeLanguageGen.Modifier replacementTable​(String... pairs)
      Creates a Modifier that will replace the (n*2)th String in pairs with the (n*2+1)th value in pairs. Because of the state of the text at the time modifiers are run, only lower-case letters need to be searched for. This overload of replacementTable allows full regex syntax for search and replacement Strings, such as searching for "([aeiou])\\1+" to find repeated occurrences of the same vowel, and "$1" in this example to replace the repeated section with only the first vowel. The ordering of pairs matters if a later search contains an earlier search (the earlier one will be replaced first, possibly making the later search not match), or if an earlier replacement causes a later one to become valid.
      Parameters:
      pairs - array or vararg of alternating Strings to search for and Strings to replace with; replacements happen in order
      Returns:
      a Modifier that can be added to a FakeLanguageGen with its addModifiers() method
    • insertVowel

      public static FakeLanguageGen.Modifier insertVowel​(String insertion, double chance)
      Adds the potential for the String insertion to be used as a vowel in addition to the vowels that the language already uses; insertion will replace an existing vowel (at any point in a word that had a vowel generated) with a probability of chance, so chance should be low (0.1 at most) unless you want the newly-inserted vowel to be likely to be present in every word of some sentences.
      Parameters:
      insertion - the String to use as an additional vowel
      chance - the chance for a vowel cluster to be replaced with insertion; normally 0.1 or less
      Returns:
      a Modifier that can be added to a FakeLanguageGen with its addModifiers() method
    • insertConsonant

      public static FakeLanguageGen.Modifier insertConsonant​(String insertion, double chance)
      Adds the potential for the String insertion to be used as a consonant in addition to the consonants that the language already uses; insertion will replace an existing consonant (at any point in a word that had a consonant generated) with a probability of chance, so chance should be low (0.1 at most) unless you want the newly-inserted consonant to be likely to be present in every word of some sentences.
      Parameters:
      insertion - the String to use as an additional consonant
      chance - the chance for a consonant cluster to be replaced with insertion; normally 0.1 or less
      Returns:
      a Modifier that can be added to a FakeLanguageGen with its addModifiers() method
    • insertOpeningVowel

      public static FakeLanguageGen.Modifier insertOpeningVowel​(String insertion, double chance)
      Adds the potential for the String insertion to be used as a vowel in addition to the vowels that the language already uses; insertion will replace an existing vowel at the start of a word with a probability of chance, so chance should be low (0.2 at most) unless you want the newly-inserted vowel to be likely to start every word of some sentences. Not all languages can start words with vowels, or do that very rarely, so this might not do anything.
      Parameters:
      insertion - the String to use as an additional opening vowel
      chance - the chance for a vowel cluster at the start of a word to be replaced with insertion; normally 0.2 or less
      Returns:
      a Modifier that can be added to a FakeLanguageGen with its addModifiers() method
    • insertOpeningConsonant

      public static FakeLanguageGen.Modifier insertOpeningConsonant​(String insertion, double chance)
      Adds the potential for the String insertion to be used as a consonant in addition to the consonants that the language already uses; insertion will replace an existing consonant at the start of a word with a probability of chance, so chance should be low (0.2 at most) unless you want the newly-inserted consonant to be likely to start every word of some sentences. Not all languages can start words with consonants, or do that very rarely, so this might not do anything.
      Parameters:
      insertion - the String to use as an additional opening consonant
      chance - the chance for a consonant cluster at the start of a word to be replaced with insertion; normally 0.2 or less
      Returns:
      a Modifier that can be added to a FakeLanguageGen with its addModifiers() method
    • insertClosingVowel

      public static FakeLanguageGen.Modifier insertClosingVowel​(String insertion, double chance)
      Adds the potential for the String insertion to be used as a vowel in addition to the vowels that the language already uses; insertion will replace an existing vowel at the end of a word with a probability of chance, so chance should be low (0.2 at most) unless you want the newly-inserted vowel to be likely to end every word of some sentences. Not all languages can end words with vowels, or do that very rarely, so this might not do anything.
      Parameters:
      insertion - the String to use as an additional closing vowel
      chance - the chance for a vowel cluster at the end of a word to be replaced with insertion; normally 0.2 or less
      Returns:
      a Modifier that can be added to a FakeLanguageGen with its addModifiers() method
    • insertClosingConsonant

      public static FakeLanguageGen.Modifier insertClosingConsonant​(String insertion, double chance)
      Adds the potential for the String insertion to be used as a consonant in addition to the consonants that the language already uses; insertion will replace an existing consonant at the end of a word with a probability of chance, so chance should be low (0.2 at most) unless you want the newly-inserted consonant to be likely to end every word of some sentences. Not all languages can end words with consonants, or do that very rarely, so this might not do anything.
      Parameters:
      insertion - the String to use as an additional closing consonant
      chance - the chance for a consonant cluster at the end of a word to be replaced with insertion; normally 0.2 or less
      Returns:
      a Modifier that can be added to a FakeLanguageGen with its addModifiers() method
    • equals

      public boolean equals​(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • serializeToString

    • deserializeFromString