source: trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/ui/commands/CMDtrainPPM.java @ 664

Last change on this file since 664 was 664, checked in by sherbold, 12 years ago
  • modified Command.help(): the help now returns a string with its usage instead of writing directly to the console
  • modified listCommands: now writes the help string of each command instead of just the name; this way, the parameters are displayed directly
  • moved listCommands from quest-ui-core to java-utils
File size: 1.7 KB
Line 
1package de.ugoe.cs.quest.ui.commands;
2
3import java.util.List;
4import java.util.Random;
5
6import de.ugoe.cs.quest.usageprofiles.PredictionByPartialMatch;
7import de.ugoe.cs.quest.usageprofiles.TrieBasedModel;
8
9/**
10 * <p>
11 * Command that trains Prediction by Partial Match (PPM) models.
12 * </p>
13 *
14 * @author Steffen Herbold
15 * @version 2.0
16 */
17public class CMDtrainPPM extends AbstractTrainCommand {
18
19        /**
20         * <p>
21         * Escape probability of the PPM model.
22         * </p>
23         */
24        double probEscape;
25
26        /**
27         * <p>
28         * Maximal Markov order of the PPM model.
29         * </p>
30         */
31        int maxOrder;
32
33        /**
34         * <p>
35         * Minimal Markov order of the PPM model. Default: 0
36         * </p>
37         */
38        int minOrder = 0;
39
40        /*
41         * (non-Javadoc)
42         *
43         * @see de.ugoe.cs.util.console.Command#help()
44         */
45        @Override
46        public String help() {
47                return "trainPPM <modelName> <sequencesName> <probEscape> <maxOrder> {<minOrder>}";
48        }
49
50        /**
51         * <p>
52         * Handles the parameters probEscape, maxOrder, and minOrder.
53         * </p>
54         *
55         * @see de.ugoe.cs.quest.ui.commands.AbstractTrainCommand#handleOptionalParameters(java.util.List)
56         */
57        @Override
58        void handleAdditionalParameters(List<Object> parameters) throws Exception {
59                probEscape = Double.parseDouble((String) parameters.get(2));
60                maxOrder = Integer.parseInt((String) parameters.get(3));
61                if (parameters.size() == 5) {
62                        minOrder = Integer.parseInt((String) parameters.get(4));
63                }
64        }
65
66        /*
67         * (non-Javadoc)
68         *
69         * @see de.ugoe.cs.quest.ui.commands.AbstractTrainCommand#createModel()
70         */
71        @Override
72        TrieBasedModel createModel() {
73                return new PredictionByPartialMatch(maxOrder, minOrder, new Random(),
74                                probEscape);
75        }
76
77}
Note: See TracBrowser for help on using the repository browser.