source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDtrainMarkovModel.java @ 186

Last change on this file since 186 was 184, checked in by sherbold, 13 years ago
  • refactored commands for the training of models (trainDFA, trainMarkovModel, trainPPM) by extracting one common abstract superclass

+ added command updateModel for model reinforcement

File size: 1.5 KB
Line 
1package de.ugoe.cs.eventbench.commands;
2
3import java.util.List;
4import java.util.Random;
5
6import de.ugoe.cs.eventbench.models.FirstOrderMarkovModel;
7import de.ugoe.cs.eventbench.models.HighOrderMarkovModel;
8import de.ugoe.cs.eventbench.models.TrieBasedModel;
9import de.ugoe.cs.util.console.Console;
10
11/**
12 * <p>
13 * Command to train first-order and high-order Markov models.
14 * </p>
15 *
16 * @author Steffen Herbold
17 * @version 2.0
18 */
19public class CMDtrainMarkovModel extends AbstractTrainCommand {
20
21        /**
22         * <p>
23         * Order of the Markov model.
24         * </p>
25         */
26        int order;
27
28        /*
29         * (non-Javadoc)
30         *
31         * @see de.ugoe.cs.util.console.Command#help()
32         */
33        @Override
34        public void help() {
35                Console.println("Usage: trainMarkovModel <modelName> <sequencesName> {<order>}");
36        }
37
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));
49                }
50        }
51
52        /*
53         * (non-Javadoc)
54         *
55         * @see de.ugoe.cs.eventbench.commands.AbstractTrainCommand#createModel()
56         */
57        @Override
58        TrieBasedModel createModel() {
59                if (order == 1) {
60                        return new FirstOrderMarkovModel(new Random());
61                } else {
62                        return new HighOrderMarkovModel(order, new Random());
63                }
64        }
65
66}
Note: See TracBrowser for help on using the repository browser.