summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java
diff options
context:
space:
mode:
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java52
1 files changed, 26 insertions, 26 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java b/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java
index 131e507..78db7d8 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java
@@ -7,8 +7,8 @@ import bjc.utils.data.IPair;
import bjc.utils.data.Pair;
import bjc.utils.funcdata.FunctionalList;
import bjc.utils.funcdata.FunctionalMap;
-import bjc.utils.funcdata.IFunctionalList;
-import bjc.utils.funcdata.IFunctionalMap;
+import bjc.utils.funcdata.IList;
+import bjc.utils.funcdata.IMap;
/**
* A random grammar, where certain rules will come up more often than
@@ -28,7 +28,7 @@ public class WeightedGrammar<E> {
/**
* The rules currently in this grammar
*/
- protected IFunctionalMap<E, WeightedRandom<IFunctionalList<E>>> rules;
+ protected IMap<E, WeightedRandom<IList<E>>> rules;
/**
* The random number generator used for random numbers
@@ -38,7 +38,7 @@ public class WeightedGrammar<E> {
/**
* All of the subgrammars of this grammar
*/
- protected IFunctionalMap<E, WeightedGrammar<E>> subgrammars;
+ protected IMap<E, WeightedGrammar<E>> subgrammars;
/**
* Create a new weighted grammar.
@@ -77,7 +77,7 @@ public class WeightedGrammar<E> {
* The case being added.
*/
public void addCase(E ruleName, int probability,
- IFunctionalList<E> cse) {
+ IList<E> cse) {
if (ruleName == null) {
throw new NullPointerException("Rule name must be not null");
} else if (cse == null) {
@@ -146,7 +146,7 @@ public class WeightedGrammar<E> {
* @return Whether or not the rule was succesfully added.
*/
public boolean addRule(E name,
- WeightedRandom<IFunctionalList<E>> cases) {
+ WeightedRandom<IList<E>> cases) {
if (name == null) {
throw new NullPointerException("Name must not be null");
} else if (cases == null) {
@@ -222,15 +222,15 @@ public class WeightedGrammar<E> {
* The rule to test.
* @return A set of sentances generated by the specified rule.
*/
- public IFunctionalList<IFunctionalList<E>> generateDebugValues(
+ public IList<IList<E>> generateDebugValues(
E ruleName) {
if (ruleName == null) {
throw new NullPointerException("Rule name must not be null");
}
- IFunctionalList<IFunctionalList<E>> returnedList = new FunctionalList<>();
+ IList<IList<E>> returnedList = new FunctionalList<>();
- WeightedRandom<IFunctionalList<E>> ruleGenerator = rules
+ WeightedRandom<IList<E>> ruleGenerator = rules
.get(ruleName);
for (int i = 0; i < 10; i++) {
@@ -255,7 +255,7 @@ public class WeightedGrammar<E> {
* @return A randomly generated sentance from the specified initial
* rule.
*/
- public <T> IFunctionalList<T> generateGenericValues(E initRule,
+ public <T> IList<T> generateGenericValues(E initRule,
Function<E, T> tokenTransformer, T spacer) {
if (initRule == null) {
throw new NullPointerException(
@@ -266,7 +266,7 @@ public class WeightedGrammar<E> {
throw new NullPointerException("Spacer must not be null");
}
- IFunctionalList<T> returnedList = new FunctionalList<>();
+ IList<T> returnedList = new FunctionalList<>();
if (subgrammars.containsKey(initRule)) {
subgrammars.get(initRule).generateGenericValues(initRule,
@@ -309,7 +309,7 @@ public class WeightedGrammar<E> {
* @return A list of random grammar elements generated by the specified
* rule.
*/
- public IFunctionalList<E> generateListValues(E initRule, E spacer) {
+ public IList<E> generateListValues(E initRule, E spacer) {
return generateGenericValues(initRule, strang -> strang, spacer);
}
@@ -336,7 +336,7 @@ public class WeightedGrammar<E> {
*
* @return The set of all rule names in this grammar
*/
- public IFunctionalList<E> getRuleNames() {
+ public IList<E> getRuleNames() {
return rules.keyList();
}
@@ -389,16 +389,16 @@ public class WeightedGrammar<E> {
"Number of times to prefix must be positive.");
}
- WeightedRandom<IFunctionalList<E>> rule = rules.get(ruleName);
+ WeightedRandom<IList<E>> rule = rules.get(ruleName);
- IFunctionalList<IPair<Integer, IFunctionalList<E>>> newResults = new FunctionalList<>();
+ IList<IPair<Integer, IList<E>>> newResults = new FunctionalList<>();
rule.getValues().forEach((pair) -> {
- IFunctionalList<IFunctionalList<E>> newRule = new FunctionalList<>();
+ IList<IList<E>> newRule = new FunctionalList<>();
for (int i = 1; i <= numberOfTimes; i++) {
- IFunctionalList<E> newCase = pair.merge((left, right) -> {
- IFunctionalList<E> returnVal = new FunctionalList<>();
+ IList<E> newCase = pair.merge((left, right) -> {
+ IList<E> returnVal = new FunctionalList<>();
for (E val : right.toIterable()) {
returnVal.add(val);
@@ -449,13 +449,13 @@ public class WeightedGrammar<E> {
"Prefix token must not be null");
}
- WeightedRandom<IFunctionalList<E>> rule = rules.get(ruleName);
+ WeightedRandom<IList<E>> rule = rules.get(ruleName);
- IFunctionalList<IPair<Integer, IFunctionalList<E>>> newResults = new FunctionalList<>();
+ IList<IPair<Integer, IList<E>>> newResults = new FunctionalList<>();
rule.getValues().forEach((pair) -> {
- IFunctionalList<E> newCase = pair.merge((left, right) -> {
- IFunctionalList<E> returnVal = new FunctionalList<>();
+ IList<E> newCase = pair.merge((left, right) -> {
+ IList<E> returnVal = new FunctionalList<>();
for (E val : right.toIterable()) {
returnVal.add(val);
@@ -503,13 +503,13 @@ public class WeightedGrammar<E> {
"Prefix token must not be null");
}
- WeightedRandom<IFunctionalList<E>> rule = rules.get(ruleName);
+ WeightedRandom<IList<E>> rule = rules.get(ruleName);
- IFunctionalList<IPair<Integer, IFunctionalList<E>>> newResults = new FunctionalList<>();
+ IList<IPair<Integer, IList<E>>> newResults = new FunctionalList<>();
rule.getValues().forEach((par) -> {
- IFunctionalList<E> newCase = par.merge((left, right) -> {
- IFunctionalList<E> returnVal = new FunctionalList<>();
+ IList<E> newCase = par.merge((left, right) -> {
+ IList<E> returnVal = new FunctionalList<>();
for (E val : right.toIterable()) {
returnVal.add(val);