[927] | 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 |
|
---|
[922] | 15 | package de.ugoe.cs.autoquest.commands.usage;
|
---|
[1] | 16 |
|
---|
| 17 | import java.util.List;
|
---|
[8] | 18 | import java.util.Random;
|
---|
[1] | 19 |
|
---|
[922] | 20 | import de.ugoe.cs.autoquest.usageprofiles.PredictionByPartialMatch;
|
---|
| 21 | import de.ugoe.cs.autoquest.usageprofiles.TrieBasedModel;
|
---|
[1] | 22 |
|
---|
[171] | 23 | /**
|
---|
| 24 | * <p>
|
---|
| 25 | * Command that trains Prediction by Partial Match (PPM) models.
|
---|
| 26 | * </p>
|
---|
| 27 | *
|
---|
| 28 | * @author Steffen Herbold
|
---|
[184] | 29 | * @version 2.0
|
---|
[171] | 30 | */
|
---|
[184] | 31 | public class CMDtrainPPM extends AbstractTrainCommand {
|
---|
[1] | 32 |
|
---|
[184] | 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 |
|
---|
[171] | 54 | /*
|
---|
| 55 | * (non-Javadoc)
|
---|
| 56 | *
|
---|
| 57 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
| 58 | */
|
---|
[1] | 59 | @Override
|
---|
[664] | 60 | public String help() {
|
---|
[726] | 61 | return "trainPPM <modelname> <sequencesName> <probEscape> <maxOrder> {<minOrder>}";
|
---|
[1] | 62 | }
|
---|
| 63 |
|
---|
[184] | 64 | /**
|
---|
| 65 | * <p>
|
---|
| 66 | * Handles the parameters probEscape, maxOrder, and minOrder.
|
---|
| 67 | * </p>
|
---|
| 68 | *
|
---|
[922] | 69 | * @see de.ugoe.cs.autoquest.commands.usage.AbstractTrainCommand#handleOptionalParameters(java.util.List)
|
---|
[184] | 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 |
|
---|
[171] | 80 | /*
|
---|
| 81 | * (non-Javadoc)
|
---|
| 82 | *
|
---|
[922] | 83 | * @see de.ugoe.cs.autoquest.ui.commands.AbstractTrainCommand#createModel()
|
---|
[171] | 84 | */
|
---|
[1] | 85 | @Override
|
---|
[184] | 86 | TrieBasedModel createModel() {
|
---|
| 87 | return new PredictionByPartialMatch(maxOrder, minOrder, new Random(),
|
---|
| 88 | probEscape);
|
---|
[1] | 89 | }
|
---|
| 90 |
|
---|
| 91 | }
|
---|