[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.usageprofiles;
|
---|
[762] | 16 |
|
---|
| 17 | import java.util.ArrayList;
|
---|
| 18 | import java.util.List;
|
---|
| 19 | import java.util.Random;
|
---|
| 20 |
|
---|
[922] | 21 | import de.ugoe.cs.autoquest.eventcore.Event;
|
---|
| 22 | import de.ugoe.cs.autoquest.usageprofiles.TrieBasedModel;
|
---|
[762] | 23 |
|
---|
| 24 | public 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 | } |
---|