diff options
Diffstat (limited to 'RGens/src/main/java/bjc/rgens/text/markov')
| -rw-r--r--[-rwxr-xr-x] | RGens/src/main/java/bjc/rgens/text/markov/Markov.java | 27 | ||||
| -rw-r--r-- | RGens/src/main/java/bjc/rgens/text/markov/StandaloneMarkov.java | 16 | ||||
| -rw-r--r-- | RGens/src/main/java/bjc/rgens/text/markov/StandaloneTextGenerator.java | 8 | ||||
| -rw-r--r--[-rwxr-xr-x] | RGens/src/main/java/bjc/rgens/text/markov/TextGenerator.java | 6 |
4 files changed, 29 insertions, 28 deletions
diff --git a/RGens/src/main/java/bjc/rgens/text/markov/Markov.java b/RGens/src/main/java/bjc/rgens/text/markov/Markov.java index 9eb4134..df8b06c 100755..100644 --- a/RGens/src/main/java/bjc/rgens/text/markov/Markov.java +++ b/RGens/src/main/java/bjc/rgens/text/markov/Markov.java @@ -6,19 +6,19 @@ import java.util.*; /** * Represents a k-character substring. Can give a pseudo-random suffix character * based on probability. - * + * * @author Daniel Friedman (Fall 2011) * */ public class Markov { - String substring; - int count = 0; + String substring; + int count = 0; TreeMap<Character, Integer> map; /** * Constructs a Markov object from a given substring. - * + * * @param substr * the given substring. */ @@ -33,7 +33,7 @@ public class Markov { /** * Constructs a Markov object from a given substring and suffix * character. Suffix characters are stored in a TreeMap. - * + * * @param substr * the specified substring. * @param suffix @@ -57,7 +57,7 @@ public class Markov { /** * Adds a suffix character to the TreeMap. - * + * * @param c * the suffix character to be added. */ @@ -73,7 +73,7 @@ public class Markov { /** * Gives the frequency count of a suffix character; that is, the number * of times the specified suffix follows the substring in a text. - * + * * @param c * the specified suffix. * @return the frequency count. @@ -88,7 +88,7 @@ public class Markov { /** * Gives a percentage of frequency count / number of total suffixes. - * + * * @param c * @return the ratio of frequency count of a single character to the * total number of suffixes @@ -103,7 +103,7 @@ public class Markov { /** * Finds whether or not the given suffix is in the TreeMap. - * + * * @param c * the given suffix. * @return True if the suffix exists in the TreeMap, false otherwise. @@ -118,7 +118,7 @@ public class Markov { /** * Gives the number of times this substring occurs in a text. - * + * * @return said number of times. */ public int count() { @@ -127,7 +127,7 @@ public class Markov { /** * Gives the TreeMap. - * + * * @return the TreeMap. */ public TreeMap<Character, Integer> getMap() { @@ -142,7 +142,7 @@ public class Markov { * indices in the ArrayList, the probability of getting a more common * suffix is greater than the probability of getting a less common * suffix. - * + * * @return the pseudo-random suffix. */ public char random() { @@ -170,7 +170,7 @@ public class Markov { /** * Gives a String representation of the Markov object. - * + * * @return said String representation. */ @Override @@ -183,6 +183,7 @@ public class Markov { int value = entry.getValue(); ret += "\n" + "Suffix: " + key + ", frequency count: " + value; } + return ret; } } diff --git a/RGens/src/main/java/bjc/rgens/text/markov/StandaloneMarkov.java b/RGens/src/main/java/bjc/rgens/text/markov/StandaloneMarkov.java index 8934daa..29f8446 100644 --- a/RGens/src/main/java/bjc/rgens/text/markov/StandaloneMarkov.java +++ b/RGens/src/main/java/bjc/rgens/text/markov/StandaloneMarkov.java @@ -4,25 +4,25 @@ import java.util.Map; /** * A standalone Markov generator. - * + * * @author bjculkin * */ public class StandaloneMarkov { private int ord; - private Map<String, Markov> hash; - private String first; + private Map<String, Markov> hash; + private String first; /** * Create a new standalone Markov generator. - * + * * @param order * The order of this generator. - * + * * @param markovHash * The generators to use. - * + * * @param firstSub * The string to start out with. */ @@ -34,10 +34,10 @@ public class StandaloneMarkov { /** * Generate random text from the markov generator. - * + * * @param charsToGenerate * The number of characters of text to generate. - * + * * @return The randomly generate text. */ public String generateTextFromMarkov(int charsToGenerate) { diff --git a/RGens/src/main/java/bjc/rgens/text/markov/StandaloneTextGenerator.java b/RGens/src/main/java/bjc/rgens/text/markov/StandaloneTextGenerator.java index 17cd670..c6eea0d 100644 --- a/RGens/src/main/java/bjc/rgens/text/markov/StandaloneTextGenerator.java +++ b/RGens/src/main/java/bjc/rgens/text/markov/StandaloneTextGenerator.java @@ -7,20 +7,20 @@ import java.util.Map; /** * Create a Markov generate from a provided source. - * + * * @author bjculkin * */ public class StandaloneTextGenerator { /** * Build a markov generator from a provided source. - * + * * @param order * The markov order to use. - * + * * @param reader * The source to seed the generator from. - * + * * @return The markov generator for the provided text. */ public static StandaloneMarkov generateMarkovMap(int order, Reader reader) { diff --git a/RGens/src/main/java/bjc/rgens/text/markov/TextGenerator.java b/RGens/src/main/java/bjc/rgens/text/markov/TextGenerator.java index 7d20d79..0ec40df 100755..100644 --- a/RGens/src/main/java/bjc/rgens/text/markov/TextGenerator.java +++ b/RGens/src/main/java/bjc/rgens/text/markov/TextGenerator.java @@ -4,20 +4,20 @@ import java.io.*; /** * Generate text from a markov model of an input text - * + * * @author ben * */ public class TextGenerator { /** * Main method. - * + * * @param args * when used with three arguments, the first represents * the k-order of the Markov objects. The second * represents the number of characters to print out. The * third represents the file to be read. - * + * * When used with two arguments, the first represents the * k-order of the Markov objects, and the second * represents the file to be read. The generated text |
