source: trunk/autoquest-test-utils/src/main/java/de/ugoe/cs/autoquest/usageprofiles/MockTrieBasedModel.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: 1.4 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.usageprofiles;
16
17import java.util.ArrayList;
18import java.util.List;
19import java.util.Random;
20
21import de.ugoe.cs.autoquest.eventcore.Event;
22import de.ugoe.cs.autoquest.usageprofiles.TrieBasedModel;
23
24public class MockTrieBasedModel extends TrieBasedModel {
25        private static final long serialVersionUID = 1L;
26
27        public MockTrieBasedModel(int markovOrder, Random r) {
28                super(markovOrder, r);
29        }
30
31        @Override
32        public double getProbability(List<Event> context,
33                        Event symbol) {
34                List<Event> list = new ArrayList<Event>();
35                if( context.isEmpty() ) {
36                        return 2;
37                }
38                list.add(context.get(context.size()-1));
39                if( trie.find(list).getFollowingSymbols().contains(symbol) ) {
40                        return 1;
41                } else {
42                        return 0;
43                }
44        }
45}
Note: See TracBrowser for help on using the repository browser.