diff options
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.java | 18 |
1 files changed, 7 insertions, 11 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 78db7d8..fe10741 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java +++ b/BJC-Utils2/src/main/java/bjc/utils/gen/WeightedGrammar.java @@ -23,7 +23,7 @@ public class WeightedGrammar<E> { /** * The initial rule of the grammar */ - protected String initialRule; + protected String initialRule; /** * The rules currently in this grammar @@ -33,12 +33,12 @@ public class WeightedGrammar<E> { /** * The random number generator used for random numbers */ - private Random rng; + private Random rng; /** * All of the subgrammars of this grammar */ - protected IMap<E, WeightedGrammar<E>> subgrammars; + protected IMap<E, WeightedGrammar<E>> subgrammars; /** * Create a new weighted grammar. @@ -76,8 +76,7 @@ public class WeightedGrammar<E> { * @param cse * The case being added. */ - public void addCase(E ruleName, int probability, - IList<E> cse) { + public void addCase(E ruleName, int probability, IList<E> cse) { if (ruleName == null) { throw new NullPointerException("Rule name must be not null"); } else if (cse == null) { @@ -145,8 +144,7 @@ public class WeightedGrammar<E> { * The set of cases for the rule. * @return Whether or not the rule was succesfully added. */ - public boolean addRule(E name, - WeightedRandom<IList<E>> cases) { + public boolean addRule(E name, WeightedRandom<IList<E>> cases) { if (name == null) { throw new NullPointerException("Name must not be null"); } else if (cases == null) { @@ -222,16 +220,14 @@ public class WeightedGrammar<E> { * The rule to test. * @return A set of sentances generated by the specified rule. */ - public IList<IList<E>> generateDebugValues( - E ruleName) { + public IList<IList<E>> generateDebugValues(E ruleName) { if (ruleName == null) { throw new NullPointerException("Rule name must not be null"); } IList<IList<E>> returnedList = new FunctionalList<>(); - WeightedRandom<IList<E>> ruleGenerator = rules - .get(ruleName); + WeightedRandom<IList<E>> ruleGenerator = rules.get(ruleName); for (int i = 0; i < 10; i++) { returnedList.add(ruleGenerator.generateValue()); |
