Last change
on this file since 236 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
|
Line | |
---|
1 | package de.ugoe.cs.eventbench.commands;
|
---|
2 |
|
---|
3 | import java.util.List;
|
---|
4 | import java.util.Random;
|
---|
5 |
|
---|
6 | import de.ugoe.cs.eventbench.models.FirstOrderMarkovModel;
|
---|
7 | import de.ugoe.cs.eventbench.models.HighOrderMarkovModel;
|
---|
8 | import de.ugoe.cs.eventbench.models.TrieBasedModel;
|
---|
9 | import 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 | */
|
---|
19 | public 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 | } else {
|
---|
50 | order = 1;
|
---|
51 | }
|
---|
52 | }
|
---|
53 |
|
---|
54 | /*
|
---|
55 | * (non-Javadoc)
|
---|
56 | *
|
---|
57 | * @see de.ugoe.cs.eventbench.commands.AbstractTrainCommand#createModel()
|
---|
58 | */
|
---|
59 | @Override
|
---|
60 | TrieBasedModel createModel() {
|
---|
61 | if (order == 1) {
|
---|
62 | return new FirstOrderMarkovModel(new Random());
|
---|
63 | } else {
|
---|
64 | return new HighOrderMarkovModel(order, new Random());
|
---|
65 | }
|
---|
66 | }
|
---|
67 |
|
---|
68 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.