Last change
on this file since 394 was
193,
checked in by sherbold, 13 years ago
|
- fixed bug: default value for model order was not set correctly
|
File size:
1.5 KB
|
Rev | Line | |
---|
[1] | 1 | package de.ugoe.cs.eventbench.commands;
|
---|
| 2 |
|
---|
| 3 | import java.util.List;
|
---|
[18] | 4 | import java.util.Random;
|
---|
[1] | 5 |
|
---|
[18] | 6 | import de.ugoe.cs.eventbench.models.FirstOrderMarkovModel;
|
---|
| 7 | import de.ugoe.cs.eventbench.models.HighOrderMarkovModel;
|
---|
[184] | 8 | import de.ugoe.cs.eventbench.models.TrieBasedModel;
|
---|
[1] | 9 | import de.ugoe.cs.util.console.Console;
|
---|
| 10 |
|
---|
[171] | 11 | /**
|
---|
| 12 | * <p>
|
---|
| 13 | * Command to train first-order and high-order Markov models.
|
---|
| 14 | * </p>
|
---|
| 15 | *
|
---|
| 16 | * @author Steffen Herbold
|
---|
[184] | 17 | * @version 2.0
|
---|
[171] | 18 | */
|
---|
[184] | 19 | public class CMDtrainMarkovModel extends AbstractTrainCommand {
|
---|
[1] | 20 |
|
---|
[184] | 21 | /**
|
---|
| 22 | * <p>
|
---|
| 23 | * Order of the Markov model.
|
---|
| 24 | * </p>
|
---|
| 25 | */
|
---|
| 26 | int order;
|
---|
| 27 |
|
---|
[171] | 28 | /*
|
---|
| 29 | * (non-Javadoc)
|
---|
| 30 | *
|
---|
| 31 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
| 32 | */
|
---|
[1] | 33 | @Override
|
---|
| 34 | public void help() {
|
---|
[184] | 35 | Console.println("Usage: trainMarkovModel <modelName> <sequencesName> {<order>}");
|
---|
[1] | 36 | }
|
---|
| 37 |
|
---|
[184] | 38 | /**
|
---|
| 39 | * <p>
|
---|
| 40 | * Handles the parameter order.
|
---|
| 41 | * </p>
|
---|
| 42 | *
|
---|
| 43 | * @see de.ugoe.cs.eventbench.commands.AbstractTrainCommand#handleOptionalParameters(java.util.List)
|
---|
| 44 | */
|
---|
| 45 | @Override
|
---|
| 46 | void handleAdditionalParameters(List<Object> parameters) throws Exception {
|
---|
| 47 | if (parameters.size() >= 3) {
|
---|
| 48 | order = Integer.parseInt((String) parameters.get(2));
|
---|
[193] | 49 | } else {
|
---|
| 50 | order = 1;
|
---|
[184] | 51 | }
|
---|
| 52 | }
|
---|
| 53 |
|
---|
[171] | 54 | /*
|
---|
| 55 | * (non-Javadoc)
|
---|
| 56 | *
|
---|
[184] | 57 | * @see de.ugoe.cs.eventbench.commands.AbstractTrainCommand#createModel()
|
---|
[171] | 58 | */
|
---|
[1] | 59 | @Override
|
---|
[184] | 60 | TrieBasedModel createModel() {
|
---|
| 61 | if (order == 1) {
|
---|
| 62 | return new FirstOrderMarkovModel(new Random());
|
---|
| 63 | } else {
|
---|
| 64 | return new HighOrderMarkovModel(order, new Random());
|
---|
[1] | 65 | }
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.