summaryrefslogtreecommitdiff
path: root/RGens/src/main/java/bjc
diff options
context:
space:
mode:
Diffstat (limited to 'RGens/src/main/java/bjc')
-rwxr-xr-xRGens/src/main/java/bjc/RGens/text/markov/FrequencyCounter.java62
-rwxr-xr-xRGens/src/main/java/bjc/RGens/text/markov/SuffixCounter.java88
2 files changed, 0 insertions, 150 deletions
diff --git a/RGens/src/main/java/bjc/RGens/text/markov/FrequencyCounter.java b/RGens/src/main/java/bjc/RGens/text/markov/FrequencyCounter.java
deleted file mode 100755
index ccc8cb5..0000000
--- a/RGens/src/main/java/bjc/RGens/text/markov/FrequencyCounter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package bjc.RGens.text.markov;
-
-import java.util.*;
-
-/**
- * Counts the frequencies of k-length substrings of input text.
- *
- * @author Daniel Friedman
- *
- */
-public class FrequencyCounter {
-
- /**
- * Main method
- *
- * @param args
- * CLI args
- */
- public static void main(String[] args) {
- String text;
-
- int k = 0;
-
- if (args.length == 1) {
- k = Integer.parseInt(args[0]);
- }
-
- System.out.print("Enter string: ");
-
- Scanner s = new Scanner(System.in);
- text = s.nextLine();
-
- Map<String, Integer> hash = new HashMap<>();
- int distinct = 0;
-
- for (int i = 0; i <= text.length() - k; i++) {
- String sub = text.substring(i, i + k);
-
- Markov m = new Markov(sub);
- m.add();
-
- if (hash.containsKey(sub)) {
- Integer count = hash.get(sub);
- hash.put(sub, count + 1);
- } else {
- hash.put(sub, m.count);
- distinct++;
- }
- }
-
- s.close();
- System.out.println(distinct + " distinct keys");
-
- Iterator<String> keys = hash.keySet().iterator();
-
- while (keys.hasNext()) {
- String key = keys.next();
- Integer value = hash.get(key);
- System.out.println(value + " " + key);
- }
- }
-}
diff --git a/RGens/src/main/java/bjc/RGens/text/markov/SuffixCounter.java b/RGens/src/main/java/bjc/RGens/text/markov/SuffixCounter.java
deleted file mode 100755
index 8f9a076..0000000
--- a/RGens/src/main/java/bjc/RGens/text/markov/SuffixCounter.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package bjc.RGens.text.markov;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Scanner;
-
-/**
- * Similar to FrequencyCounter, but also counts the suffixes for each
- * k-length substring in the text.
- *
- * @author Daniel Friedman
- *
- */
-
-public class SuffixCounter {
- /**
- * Main method
- *
- * @param args
- * CLI args
- */
- public static void main(String[] args) {
- String text;
- int k = 0;
-
- if (args.length == 1) {
- k = Integer.parseInt(args[0]);
- }
-
- System.out.print("Enter string: ");
- Scanner s = new Scanner(System.in);
- text = s.nextLine();
-
- Map<String, Markov> hash = new HashMap<>();
-
- int distinct = 0;
-
- for (int i = 0; i <= text.length() - k; i++) {
- String sub = text.substring(i, i + k);
- Character suffix = null;
-
- if (((i + k) <= (text.length() - 1))) {
- suffix = text.charAt(i + k);
- }
-
- if (hash.containsKey(sub)) {
- Markov temp = hash.get(sub);
-
- if (!(suffix == null)) {
- temp.add(suffix);
- hash.put(sub, temp);
- }
-
- } else {
- Markov m;
-
- if (!(suffix == null)) {
- m = new Markov(sub, suffix);
- hash.put(sub, m);
- distinct++;
- }
- }
- }
-
- System.out.println(distinct + " distinct keys");
- Iterator<String> keys = hash.keySet().iterator();
-
- while (keys.hasNext()) {
- String hashKey = keys.next();
-
- Markov hashValue = hash.get(hashKey);
- System.out.print(hashValue.count() + " " + hashKey + ":");
-
- for (Entry<Character, Integer> entry : hashValue.getMap()
- .entrySet()) {
- char suffix = entry.getKey();
- int frequencyCount = entry.getValue();
- System.out.print(" " + frequencyCount + " " + suffix);
- }
-
- System.out.println();
- }
-
- s.close();
- }
-}