source: trunk/autoquest-ui-core/src/main/java/de/ugoe/cs/autoquest/commands/usage/CMDtrainPPM.java @ 927

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
File size: 2.3 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.commands.usage;
16
17import java.util.List;
18import java.util.Random;
19
20import de.ugoe.cs.autoquest.usageprofiles.PredictionByPartialMatch;
21import de.ugoe.cs.autoquest.usageprofiles.TrieBasedModel;
22
23/**
24 * <p>
25 * Command that trains Prediction by Partial Match (PPM) models.
26 * </p>
27 *
28 * @author Steffen Herbold
29 * @version 2.0
30 */
31public class CMDtrainPPM extends AbstractTrainCommand {
32
33        /**
34         * <p>
35         * Escape probability of the PPM model.
36         * </p>
37         */
38        double probEscape;
39
40        /**
41         * <p>
42         * Maximal Markov order of the PPM model.
43         * </p>
44         */
45        int maxOrder;
46
47        /**
48         * <p>
49         * Minimal Markov order of the PPM model. Default: 0
50         * </p>
51         */
52        int minOrder = 0;
53
54        /*
55         * (non-Javadoc)
56         *
57         * @see de.ugoe.cs.util.console.Command#help()
58         */
59        @Override
60        public String help() {
61                return "trainPPM <modelname> <sequencesName> <probEscape> <maxOrder> {<minOrder>}";
62        }
63
64        /**
65         * <p>
66         * Handles the parameters probEscape, maxOrder, and minOrder.
67         * </p>
68         *
69         * @see de.ugoe.cs.autoquest.commands.usage.AbstractTrainCommand#handleOptionalParameters(java.util.List)
70         */
71        @Override
72        void handleAdditionalParameters(List<Object> parameters) throws Exception {
73                probEscape = Double.parseDouble((String) parameters.get(2));
74                maxOrder = Integer.parseInt((String) parameters.get(3));
75                if (parameters.size() == 5) {
76                        minOrder = Integer.parseInt((String) parameters.get(4));
77                }
78        }
79
80        /*
81         * (non-Javadoc)
82         *
83         * @see de.ugoe.cs.autoquest.ui.commands.AbstractTrainCommand#createModel()
84         */
85        @Override
86        TrieBasedModel createModel() {
87                return new PredictionByPartialMatch(maxOrder, minOrder, new Random(),
88                                probEscape);
89        }
90
91}
Note: See TracBrowser for help on using the repository browser.