Changeset 548 for trunk/quest-core-usageprofiles-test/src/test
- Timestamp:
- 08/16/12 14:45:03 (12 years ago)
- Location:
- trunk/quest-core-usageprofiles-test/src/test/java/de/ugoe/cs/quest/usageprofiles
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/quest-core-usageprofiles-test/src/test/java/de/ugoe/cs/quest/usageprofiles/DeterministicFiniteAutomatonTest.java
r518 r548 7 7 import de.ugoe.cs.quest.eventcore.Event; 8 8 import de.ugoe.cs.quest.usageprofiles.DeterministicFiniteAutomaton; 9 import de.ugoe.cs.quest.usageprofiles.mock.StringEventType; 9 10 10 11 import java.util.Random; … … 22 23 public class DeterministicFiniteAutomatonTest { 23 24 24 Collection<List< ? extends Event<?>>> sequences;25 Collection<List<Event>> sequences; 25 26 26 27 @Test … … 46 47 fixture.train(sequences); 47 48 48 List<Event <String>> context = new ArrayList<Event<String>>();49 context.add(new Event <String>("a"));50 context.add(new Event <String>("b"));49 List<Event> context = new ArrayList<Event>(); 50 context.add(new Event(new StringEventType("a"))); 51 context.add(new Event(new StringEventType("b"))); 51 52 52 Event <String> symbol = new Event<String>("r");53 Event symbol = new Event(new StringEventType("r")); 53 54 54 55 double result = fixture.getProbability(context, symbol); … … 63 64 fixture.train(sequences); 64 65 65 List<Event <String>> context = new ArrayList<Event<String>>();66 context.add(new Event <String>("a"));66 List<Event> context = new ArrayList<Event>(); 67 context.add(new Event(new StringEventType("a"))); 67 68 68 Event <String> symbol = new Event<String>("b");69 Event symbol = new Event(new StringEventType("b")); 69 70 70 71 double result = fixture.getProbability(context, symbol); … … 79 80 fixture.train(sequences); 80 81 81 List<Event <String>> context = new ArrayList<Event<String>>();82 context.add(new Event <String>("a"));82 List<Event> context = new ArrayList<Event>(); 83 context.add(new Event(new StringEventType("a"))); 83 84 84 Event <String> symbol = new Event<String>("c");85 Event symbol = new Event(new StringEventType("c")); 85 86 86 87 double result = fixture.getProbability(context, symbol); … … 95 96 fixture.train(sequences); 96 97 97 List<Event <String>> context = new ArrayList<Event<String>>();98 context.add(new Event <String>("a"));98 List<Event> context = new ArrayList<Event>(); 99 context.add(new Event(new StringEventType("a"))); 99 100 100 Event <String> symbol = new Event<String>("e");101 Event symbol = new Event(new StringEventType("e")); 101 102 102 103 double result = fixture.getProbability(context, symbol); … … 111 112 fixture.train(sequences); 112 113 113 List<Event <String>> context = new ArrayList<Event<String>>();114 context.add(new Event <String>("a"));114 List<Event> context = new ArrayList<Event>(); 115 context.add(new Event(new StringEventType("a"))); 115 116 116 Event <String>symbol = null;117 Event symbol = null; 117 118 118 119 fixture.getProbability(context, symbol); … … 125 126 fixture.train(sequences); 126 127 127 List<Event <String>> context = null;128 List<Event> context = null; 128 129 129 Event <String> symbol = new Event<String>("a");130 Event symbol = new Event(new StringEventType("a")); 130 131 131 132 fixture.getProbability(context, symbol); … … 134 135 @Before 135 136 public void setUp() throws Exception { 136 List<Event <?>> sequence = new ArrayList<Event<?>>();137 sequence.add(new Event <String>("a"));138 sequence.add(new Event <String>("b"));139 sequence.add(new Event <String>("r"));140 sequence.add(new Event <String>("a"));141 sequence.add(new Event <String>("c"));142 sequence.add(new Event <String>("a"));143 sequence.add(new Event <String>("d"));144 sequence.add(new Event <String>("a"));145 sequence.add(new Event <String>("b"));146 sequence.add(new Event <String>("r"));147 sequence.add(new Event <String>("a"));137 List<Event> sequence = new ArrayList<Event>(); 138 sequence.add(new Event(new StringEventType("a"))); 139 sequence.add(new Event(new StringEventType("b"))); 140 sequence.add(new Event(new StringEventType("r"))); 141 sequence.add(new Event(new StringEventType("a"))); 142 sequence.add(new Event(new StringEventType("c"))); 143 sequence.add(new Event(new StringEventType("a"))); 144 sequence.add(new Event(new StringEventType("d"))); 145 sequence.add(new Event(new StringEventType("a"))); 146 sequence.add(new Event(new StringEventType("b"))); 147 sequence.add(new Event(new StringEventType("r"))); 148 sequence.add(new Event(new StringEventType("a"))); 148 149 149 sequences = new ArrayList<List< ? extends Event<?>>>();150 sequences = new ArrayList<List<Event>>(); 150 151 sequences.add(sequence); 151 152 } -
trunk/quest-core-usageprofiles-test/src/test/java/de/ugoe/cs/quest/usageprofiles/FirstOrderMarkovModelTest.java
r518 r548 10 10 import de.ugoe.cs.quest.usageprofiles.FirstOrderMarkovModel; 11 11 import de.ugoe.cs.quest.usageprofiles.FirstOrderMarkovModel.MarkovEdge; 12 import de.ugoe.cs.quest.usageprofiles.mock.StringEventType; 12 13 import static org.junit.Assert.*; 13 14 … … 21 22 public class FirstOrderMarkovModelTest { 22 23 23 Collection<List< ? extends Event<?>>> sequences;24 Collection<List<Event>> sequences; 24 25 25 26 @Test … … 72 73 @Before 73 74 public void setUp() throws Exception { 74 List<Event <?>> sequence = new ArrayList<Event<?>>();75 sequence.add(new Event <String>("a"));76 sequence.add(new Event <String>("b"));77 sequence.add(new Event <String>("r"));78 sequence.add(new Event <String>("a"));79 sequence.add(new Event <String>("c"));80 sequence.add(new Event <String>("a"));81 sequence.add(new Event <String>("d"));82 sequence.add(new Event <String>("a"));83 sequence.add(new Event <String>("b"));84 sequence.add(new Event <String>("r"));85 sequence.add(new Event <String>("a"));75 List<Event> sequence = new ArrayList<Event>(); 76 sequence.add(new Event(new StringEventType("a"))); 77 sequence.add(new Event(new StringEventType("b"))); 78 sequence.add(new Event(new StringEventType("r"))); 79 sequence.add(new Event(new StringEventType("a"))); 80 sequence.add(new Event(new StringEventType("c"))); 81 sequence.add(new Event(new StringEventType("a"))); 82 sequence.add(new Event(new StringEventType("d"))); 83 sequence.add(new Event(new StringEventType("a"))); 84 sequence.add(new Event(new StringEventType("b"))); 85 sequence.add(new Event(new StringEventType("r"))); 86 sequence.add(new Event(new StringEventType("a"))); 86 87 87 sequences = new ArrayList<List< ? extends Event<?>>>();88 sequences = new ArrayList<List<Event>>(); 88 89 sequences.add(sequence); 89 90 } -
trunk/quest-core-usageprofiles-test/src/test/java/de/ugoe/cs/quest/usageprofiles/HighOrderMarkovModelTest.java
r518 r548 7 7 import de.ugoe.cs.quest.eventcore.Event; 8 8 import de.ugoe.cs.quest.usageprofiles.HighOrderMarkovModel; 9 import de.ugoe.cs.quest.usageprofiles.mock.StringEventType; 9 10 10 11 import java.util.Random; … … 22 23 public class HighOrderMarkovModelTest { 23 24 24 Collection<List< ? extends Event<?>>> sequences;25 Collection<List<Event>> sequences; 25 26 26 27 @Test … … 71 72 fixture.train(sequences); 72 73 73 List<Event <String>> context = new ArrayList<Event<String>>();74 context.add(new Event <String>("a"));75 76 Event <String> symbol = new Event<String>("b");74 List<Event> context = new ArrayList<Event>(); 75 context.add(new Event(new StringEventType("a"))); 76 77 Event symbol = new Event(new StringEventType("b")); 77 78 78 79 double result = fixture.getProbability(context, symbol); … … 88 89 fixture.train(sequences); 89 90 90 List<Event <String>> context = new ArrayList<Event<String>>();91 context.add(new Event <String>("a"));92 93 Event <String> symbol = new Event<String>("r");91 List<Event> context = new ArrayList<Event>(); 92 context.add(new Event(new StringEventType("a"))); 93 94 Event symbol = new Event(new StringEventType("r")); 94 95 95 96 double result = fixture.getProbability(context, symbol); … … 105 106 fixture.train(sequences); 106 107 107 List<Event <String>> context = new ArrayList<Event<String>>();108 context.add(new Event <String>("a"));109 110 Event <String> symbol = new Event<String>("c");108 List<Event> context = new ArrayList<Event>(); 109 context.add(new Event(new StringEventType("a"))); 110 111 Event symbol = new Event(new StringEventType("c")); 111 112 112 113 double result = fixture.getProbability(context, symbol); … … 122 123 fixture.train(sequences); 123 124 124 List<Event <?>> context = new ArrayList<Event<?>>();125 context.add(Event.STARTEVENT); 126 context.add(new Event <String>("a"));127 128 Event <String> symbol = new Event<String>("b");125 List<Event> context = new ArrayList<Event>(); 126 context.add(Event.STARTEVENT); 127 context.add(new Event(new StringEventType("a"))); 128 129 Event symbol = new Event(new StringEventType("b")); 129 130 130 131 double result = fixture.getProbability(context, symbol); … … 140 141 fixture.train(sequences); 141 142 142 List<Event <?>> context = new ArrayList<Event<?>>();143 context.add(Event.STARTEVENT); 144 context.add(new Event <String>("a"));145 146 Event <String> symbol = new Event<String>("b");143 List<Event> context = new ArrayList<Event>(); 144 context.add(Event.STARTEVENT); 145 context.add(new Event(new StringEventType("a"))); 146 147 Event symbol = new Event(new StringEventType("b")); 147 148 148 149 double result = fixture.getProbability(context, symbol); … … 158 159 fixture.train(sequences); 159 160 160 List<Event <?>> context = new ArrayList<Event<?>>();161 context.add(Event.STARTEVENT); 162 context.add(new Event <String>("b"));163 164 Event <String> symbol = new Event<String>("b");161 List<Event> context = new ArrayList<Event>(); 162 context.add(Event.STARTEVENT); 163 context.add(new Event(new StringEventType("b"))); 164 165 Event symbol = new Event(new StringEventType("b")); 165 166 166 167 double result = fixture.getProbability(context, symbol); … … 176 177 fixture.train(sequences); 177 178 178 List<Event <?>> context = new ArrayList<Event<?>>();179 context.add(Event.STARTEVENT); 180 context.add(new Event <String>("b"));181 182 Event <String> symbol = new Event<String>("a");179 List<Event> context = new ArrayList<Event>(); 180 context.add(Event.STARTEVENT); 181 context.add(new Event(new StringEventType("b"))); 182 183 Event symbol = new Event(new StringEventType("a")); 183 184 184 185 double result = fixture.getProbability(context, symbol); … … 194 195 fixture.train(sequences); 195 196 196 List<Event <?>> context = new ArrayList<Event<?>>();197 context.add(Event.STARTEVENT); 198 context.add(new Event <String>("b"));199 200 Event <String>symbol = null;197 List<Event> context = new ArrayList<Event>(); 198 context.add(Event.STARTEVENT); 199 context.add(new Event(new StringEventType("b"))); 200 201 Event symbol = null; 201 202 202 203 fixture.getProbability(context, symbol); … … 210 211 fixture.train(sequences); 211 212 212 List<Event <?>> context = null;213 214 Event <String> symbol = new Event<String>("b");213 List<Event> context = null; 214 215 Event symbol = new Event(new StringEventType("b")); 215 216 216 217 fixture.getProbability(context, symbol); … … 219 220 @Before 220 221 public void setUp() throws Exception { 221 List<Event <?>> sequence = new ArrayList<Event<?>>();222 sequence.add(new Event <String>("a"));223 sequence.add(new Event <String>("b"));224 sequence.add(new Event <String>("r"));225 sequence.add(new Event <String>("a"));226 sequence.add(new Event <String>("c"));227 sequence.add(new Event <String>("a"));228 sequence.add(new Event <String>("d"));229 sequence.add(new Event <String>("a"));230 sequence.add(new Event <String>("b"));231 sequence.add(new Event <String>("r"));232 sequence.add(new Event <String>("a"));233 234 sequences = new ArrayList<List< ? extends Event<?>>>();222 List<Event> sequence = new ArrayList<Event>(); 223 sequence.add(new Event(new StringEventType("a"))); 224 sequence.add(new Event(new StringEventType("b"))); 225 sequence.add(new Event(new StringEventType("r"))); 226 sequence.add(new Event(new StringEventType("a"))); 227 sequence.add(new Event(new StringEventType("c"))); 228 sequence.add(new Event(new StringEventType("a"))); 229 sequence.add(new Event(new StringEventType("d"))); 230 sequence.add(new Event(new StringEventType("a"))); 231 sequence.add(new Event(new StringEventType("b"))); 232 sequence.add(new Event(new StringEventType("r"))); 233 sequence.add(new Event(new StringEventType("a"))); 234 235 sequences = new ArrayList<List<Event>>(); 235 236 sequences.add(sequence); 236 237 } -
trunk/quest-core-usageprofiles-test/src/test/java/de/ugoe/cs/quest/usageprofiles/MockTrieBasedModel.java
r518 r548 16 16 17 17 @Override 18 public double getProbability(List< ? extends Event<?>> context,19 Event <?>symbol) {20 List<Event <?>> list = new ArrayList<Event<?>>();18 public double getProbability(List<Event> context, 19 Event symbol) { 20 List<Event> list = new ArrayList<Event>(); 21 21 if( context.isEmpty() ) { 22 22 return 2; -
trunk/quest-core-usageprofiles-test/src/test/java/de/ugoe/cs/quest/usageprofiles/ModelFlattenerTest.java
r518 r548 1 1 2 package de.ugoe.cs.quest.usageprofiles; 2 3 … … 14 15 import de.ugoe.cs.quest.usageprofiles.PredictionByPartialMatch; 15 16 import de.ugoe.cs.quest.usageprofiles.TrieNode; 17 import de.ugoe.cs.quest.usageprofiles.mock.StringEventType; 16 18 import static org.junit.Assert.*; 17 19 18 20 /** 19 * The class <code>ModelFlattenerTest</code> contains tests for the class <code>{@link ModelFlattener}</code>. 20 * 21 * The class <code>ModelFlattenerTest</code> contains tests for the class 22 * <code>{@link ModelFlattener}</code>. 23 * 21 24 * @author Steffen Herbold 22 25 * @version 1.0 23 26 */ 24 27 public class ModelFlattenerTest { 25 26 List<Event<?>> sequence;27 28 private static void assertCollectionContent(Collection<?> c1, Collection<?> c2) {29 assertEquals(c1.size(), c2.size());30 for( Object obj : c1 ) {31 assertTrue(c2.contains(obj));32 }33 }34 35 @Test36 public void testFlattenHighOrderMarkovModel_1()37 throws Exception {38 ModelFlattener fixture = new ModelFlattener();39 HighOrderMarkovModel model = new HighOrderMarkovModel(2, new Random());40 Collection<List<? extends Event<?>>> sequences = new ArrayList<List<? extends Event<?>>>();41 sequences.add(sequence);42 model.train(sequences);43 44 Collection<Event<?>> expectedSymbols = new HashSet<Event<?>>();45 expectedSymbols.add(new Event<Object>("a-=-END"));46 expectedSymbols.add(new Event<Object>("a-=-b"));47 expectedSymbols.add(new Event<Object>("a-=-c"));48 expectedSymbols.add(new Event<Object>("a-=-d"));49 expectedSymbols.add(new Event<Object>("b-=-r"));50 expectedSymbols.add(new Event<Object>("c-=-a"));51 expectedSymbols.add(new Event<Object>("d-=-a"));52 expectedSymbols.add(new Event<Object>("r-=-a"));53 expectedSymbols.add(new Event<Object>("START-=-a"));54 28 55 FirstOrderMarkovModel result = fixture.flattenHighOrderMarkovModel(model); 56 57 assertCollectionContent(expectedSymbols, result.getEvents()); 58 59 TrieNode<Event<?>> root = result.trie.find(null); 60 TrieNode<Event<?>> root_aEnd = root.getChild(new Event<Object>("a-=-END")); 61 TrieNode<Event<?>> root_ab = root.getChild(new Event<Object>("a-=-b")); 62 TrieNode<Event<?>> root_ab_br = root_ab.getChild(new Event<Object>("b-=-r")); 63 TrieNode<Event<?>> root_ac = root.getChild(new Event<Object>("a-=-c")); 64 TrieNode<Event<?>> root_ac_ca = root_ac.getChild(new Event<Object>("c-=-a")); 65 TrieNode<Event<?>> root_ad = root.getChild(new Event<Object>("a-=-d")); 66 TrieNode<Event<?>> root_ad_da = root_ad.getChild(new Event<Object>("d-=-a")); 67 TrieNode<Event<?>> root_br = root.getChild(new Event<Object>("b-=-r")); 68 TrieNode<Event<?>> root_br_ra = root_br.getChild(new Event<Object>("r-=-a")); 69 TrieNode<Event<?>> root_ca = root.getChild(new Event<Object>("c-=-a")); 70 TrieNode<Event<?>> root_ca_ad = root_ca.getChild(new Event<Object>("a-=-d")); 71 TrieNode<Event<?>> root_da = root.getChild(new Event<Object>("d-=-a")); 72 TrieNode<Event<?>> root_da_ab = root_da.getChild(new Event<Object>("a-=-b")); 73 TrieNode<Event<?>> root_ra = root.getChild(new Event<Object>("r-=-a")); 74 TrieNode<Event<?>> root_ra_ac = root_ra.getChild(new Event<Object> ("a-=-c")); 75 TrieNode<Event<?>> root_ra_aEnd = root_ra.getChild(new Event<Object>("a-=-END")); 76 TrieNode<Event<?>> root_startA = root.getChild(new Event<Object>("START-=-a")); 77 TrieNode<Event<?>> root_startA_ab = root_startA.getChild(new Event<Object>("a-=-b")); 78 79 assertEquals(1, root_aEnd.getCount()); 80 assertTrue(root_aEnd.isLeaf()); 81 assertEquals(2, root_ab.getCount()); 82 assertEquals(1, root_ab.getChildren().size()); 83 assertEquals(2, root_ab_br.getCount()); 84 assertTrue(root_ab_br.isLeaf()); 85 assertEquals(1, root_ac.getCount()); 86 assertEquals(1, root_ac.getChildren().size()); 87 assertEquals(1, root_ac_ca.getCount()); 88 assertTrue(root_ac_ca.isLeaf()); 89 assertEquals(1, root_ad.getCount()); 90 assertEquals(1, root_ad.getChildren().size()); 91 assertEquals(1, root_ad_da.getCount()); 92 assertTrue(root_ad_da.isLeaf()); 93 assertEquals(2, root_br.getCount()); 94 assertEquals(1, root_br.getChildren().size()); 95 assertEquals(2, root_br_ra.getCount()); 96 assertTrue(root_br_ra.isLeaf()); 97 assertEquals(1, root_ca.getCount()); 98 assertEquals(1, root_ca.getChildren().size()); 99 assertEquals(1, root_ca_ad.getCount()); 100 assertTrue(root_ca_ad.isLeaf()); 101 assertEquals(1, root_da.getCount()); 102 assertEquals(1, root_da.getChildren().size()); 103 assertEquals(1, root_da_ab.getCount()); 104 assertTrue(root_da_ab.isLeaf()); 105 assertEquals(2, root_ra.getCount()); 106 assertEquals(2, root_ra.getChildren().size()); 107 assertEquals(1, root_ra_ac.getCount()); 108 assertTrue(root_ra_ac.isLeaf()); 109 assertEquals(1, root_ra_aEnd.getCount()); 110 assertTrue(root_ra_aEnd.isLeaf()); 111 assertEquals(1, root_startA.getCount()); 112 assertEquals(1, root_startA.getChildren().size()); 113 assertEquals(1, root_startA_ab.getCount()); 114 assertTrue(root_startA_ab.isLeaf()); 115 } 29 List<Event> sequence; 116 30 117 @Test 118 public void testFlattenPredictionByPartialMatch_1() 119 throws Exception { 120 ModelFlattener fixture = new ModelFlattener(); 121 PredictionByPartialMatch model = new PredictionByPartialMatch(1, new Random()); 31 private static void assertCollectionContent(Collection<?> c1, Collection<?> c2) { 32 assertEquals(c1.size(), c2.size()); 33 for (Object obj : c1) { 34 assertTrue(c2.contains(obj)); 35 } 36 } 122 37 123 FirstOrderMarkovModel result = fixture.flattenPredictionByPartialMatch(model); 124 125 assertEquals(null, result); 126 } 38 @Test 39 public void testFlattenHighOrderMarkovModel_1() throws Exception { 40 ModelFlattener fixture = new ModelFlattener(); 41 HighOrderMarkovModel model = new HighOrderMarkovModel(2, new Random()); 42 Collection<List<Event>> sequences = new ArrayList<List<Event>>(); 43 sequences.add(sequence); 44 model.train(sequences); 127 45 128 @Before 129 public void setUp() 130 throws Exception { 131 sequence = new ArrayList<Event<?>>(); 132 sequence.add(new Event<String>("a")); 133 sequence.add(new Event<String>("b")); 134 sequence.add(new Event<String>("r")); 135 sequence.add(new Event<String>("a")); 136 sequence.add(new Event<String>("c")); 137 sequence.add(new Event<String>("a")); 138 sequence.add(new Event<String>("d")); 139 sequence.add(new Event<String>("a")); 140 sequence.add(new Event<String>("b")); 141 sequence.add(new Event<String>("r")); 142 sequence.add(new Event<String>("a")); 143 } 46 Collection<Event> expectedSymbols = new HashSet<Event>(); 47 expectedSymbols.add(new Event(new StringEventType("a-=-END"))); 48 expectedSymbols.add(new Event(new StringEventType("a-=-b"))); 49 expectedSymbols.add(new Event(new StringEventType("a-=-c"))); 50 expectedSymbols.add(new Event(new StringEventType("a-=-d"))); 51 expectedSymbols.add(new Event(new StringEventType("b-=-r"))); 52 expectedSymbols.add(new Event(new StringEventType("c-=-a"))); 53 expectedSymbols.add(new Event(new StringEventType("d-=-a"))); 54 expectedSymbols.add(new Event(new StringEventType("r-=-a"))); 55 expectedSymbols.add(new Event(new StringEventType("START-=-a"))); 144 56 145 public static void main(String[] args) { 146 new org.junit.runner.JUnitCore().run(ModelFlattenerTest.class); 147 } 57 FirstOrderMarkovModel result = fixture.flattenHighOrderMarkovModel(model); 58 59 assertCollectionContent(expectedSymbols, result.getEvents()); 60 61 TrieNode<Event> root = result.trie.find(null); 62 TrieNode<Event> root_aEnd = root.getChild(new Event(new StringEventType("a-=-END"))); 63 TrieNode<Event> root_ab = root.getChild(new Event(new StringEventType("a-=-b"))); 64 TrieNode<Event> root_ab_br = root_ab.getChild(new Event(new StringEventType("b-=-r"))); 65 TrieNode<Event> root_ac = root.getChild(new Event(new StringEventType("a-=-c"))); 66 TrieNode<Event> root_ac_ca = root_ac.getChild(new Event(new StringEventType("c-=-a"))); 67 TrieNode<Event> root_ad = root.getChild(new Event(new StringEventType("a-=-d"))); 68 TrieNode<Event> root_ad_da = root_ad.getChild(new Event(new StringEventType("d-=-a"))); 69 TrieNode<Event> root_br = root.getChild(new Event(new StringEventType("b-=-r"))); 70 TrieNode<Event> root_br_ra = root_br.getChild(new Event(new StringEventType("r-=-a"))); 71 TrieNode<Event> root_ca = root.getChild(new Event(new StringEventType("c-=-a"))); 72 TrieNode<Event> root_ca_ad = root_ca.getChild(new Event(new StringEventType("a-=-d"))); 73 TrieNode<Event> root_da = root.getChild(new Event(new StringEventType("d-=-a"))); 74 TrieNode<Event> root_da_ab = root_da.getChild(new Event(new StringEventType("a-=-b"))); 75 TrieNode<Event> root_ra = root.getChild(new Event(new StringEventType("r-=-a"))); 76 TrieNode<Event> root_ra_ac = root_ra.getChild(new Event(new StringEventType("a-=-c"))); 77 TrieNode<Event> root_ra_aEnd = root_ra.getChild(new Event(new StringEventType("a-=-END"))); 78 TrieNode<Event> root_startA = root.getChild(new Event(new StringEventType("START-=-a"))); 79 TrieNode<Event> root_startA_ab = 80 root_startA.getChild(new Event(new StringEventType("a-=-b"))); 81 82 assertEquals(1, root_aEnd.getCount()); 83 assertTrue(root_aEnd.isLeaf()); 84 assertEquals(2, root_ab.getCount()); 85 assertEquals(1, root_ab.getChildren().size()); 86 assertEquals(2, root_ab_br.getCount()); 87 assertTrue(root_ab_br.isLeaf()); 88 assertEquals(1, root_ac.getCount()); 89 assertEquals(1, root_ac.getChildren().size()); 90 assertEquals(1, root_ac_ca.getCount()); 91 assertTrue(root_ac_ca.isLeaf()); 92 assertEquals(1, root_ad.getCount()); 93 assertEquals(1, root_ad.getChildren().size()); 94 assertEquals(1, root_ad_da.getCount()); 95 assertTrue(root_ad_da.isLeaf()); 96 assertEquals(2, root_br.getCount()); 97 assertEquals(1, root_br.getChildren().size()); 98 assertEquals(2, root_br_ra.getCount()); 99 assertTrue(root_br_ra.isLeaf()); 100 assertEquals(1, root_ca.getCount()); 101 assertEquals(1, root_ca.getChildren().size()); 102 assertEquals(1, root_ca_ad.getCount()); 103 assertTrue(root_ca_ad.isLeaf()); 104 assertEquals(1, root_da.getCount()); 105 assertEquals(1, root_da.getChildren().size()); 106 assertEquals(1, root_da_ab.getCount()); 107 assertTrue(root_da_ab.isLeaf()); 108 assertEquals(2, root_ra.getCount()); 109 assertEquals(2, root_ra.getChildren().size()); 110 assertEquals(1, root_ra_ac.getCount()); 111 assertTrue(root_ra_ac.isLeaf()); 112 assertEquals(1, root_ra_aEnd.getCount()); 113 assertTrue(root_ra_aEnd.isLeaf()); 114 assertEquals(1, root_startA.getCount()); 115 assertEquals(1, root_startA.getChildren().size()); 116 assertEquals(1, root_startA_ab.getCount()); 117 assertTrue(root_startA_ab.isLeaf()); 118 } 119 120 @Test 121 public void testFlattenPredictionByPartialMatch_1() throws Exception { 122 ModelFlattener fixture = new ModelFlattener(); 123 PredictionByPartialMatch model = new PredictionByPartialMatch(1, new Random()); 124 125 FirstOrderMarkovModel result = fixture.flattenPredictionByPartialMatch(model); 126 127 assertEquals(null, result); 128 } 129 130 @Before 131 public void setUp() throws Exception { 132 sequence = new ArrayList<Event>(); 133 sequence.add(new Event(new StringEventType("a"))); 134 sequence.add(new Event(new StringEventType("b"))); 135 sequence.add(new Event(new StringEventType("r"))); 136 sequence.add(new Event(new StringEventType("a"))); 137 sequence.add(new Event(new StringEventType("c"))); 138 sequence.add(new Event(new StringEventType("a"))); 139 sequence.add(new Event(new StringEventType("d"))); 140 sequence.add(new Event(new StringEventType("a"))); 141 sequence.add(new Event(new StringEventType("b"))); 142 sequence.add(new Event(new StringEventType("r"))); 143 sequence.add(new Event(new StringEventType("a"))); 144 } 145 146 public static void main(String[] args) { 147 new org.junit.runner.JUnitCore().run(ModelFlattenerTest.class); 148 } 148 149 } -
trunk/quest-core-usageprofiles-test/src/test/java/de/ugoe/cs/quest/usageprofiles/PredictionByPartialMatchTest.java
r518 r548 7 7 import de.ugoe.cs.quest.eventcore.Event; 8 8 import de.ugoe.cs.quest.usageprofiles.PredictionByPartialMatch; 9 import de.ugoe.cs.quest.usageprofiles.mock.StringEventType; 9 10 10 11 import java.util.Random; … … 22 23 public class PredictionByPartialMatchTest { 23 24 24 Collection<List< ? extends Event<?>>> sequences;25 Collection<List<Event>> sequences; 25 26 26 27 @Test … … 209 210 fixture.train(sequences); 210 211 211 List<Event <?>> context = new ArrayList<Event<?>>();212 context.add(Event.STARTEVENT); 213 context.add(new Event <String>("a"));214 215 Event <String> symbol = new Event<String>("b");212 List<Event> context = new ArrayList<Event>(); 213 context.add(Event.STARTEVENT); 214 context.add(new Event(new StringEventType("a"))); 215 216 Event symbol = new Event(new StringEventType("b")); 216 217 217 218 double result = fixture.getProbability(context, symbol); … … 230 231 fixture.train(sequences); 231 232 232 List<Event <?>> context = new ArrayList<Event<?>>();233 context.add(Event.STARTEVENT); 234 context.add(new Event <String>("a"));235 236 Event <String> symbol = new Event<String>("c");233 List<Event> context = new ArrayList<Event>(); 234 context.add(Event.STARTEVENT); 235 context.add(new Event(new StringEventType("a"))); 236 237 Event symbol = new Event(new StringEventType("c")); 237 238 238 239 double result = fixture.getProbability(context, symbol); … … 251 252 fixture.train(sequences); 252 253 253 List<Event <?>> context = new ArrayList<Event<?>>();254 context.add(Event.STARTEVENT); 255 context.add(new Event <String>("a"));256 257 Event <String> symbol = new Event<String>("b");254 List<Event> context = new ArrayList<Event>(); 255 context.add(Event.STARTEVENT); 256 context.add(new Event(new StringEventType("a"))); 257 258 Event symbol = new Event(new StringEventType("b")); 258 259 259 260 double result = fixture.getProbability(context, symbol); … … 272 273 fixture.train(sequences); 273 274 274 List<Event <?>> context = new ArrayList<Event<?>>();275 context.add(Event.STARTEVENT); 276 context.add(new Event <String>("a"));277 278 Event <String> symbol = new Event<String>("c");275 List<Event> context = new ArrayList<Event>(); 276 context.add(Event.STARTEVENT); 277 context.add(new Event(new StringEventType("a"))); 278 279 Event symbol = new Event(new StringEventType("c")); 279 280 280 281 double result = fixture.getProbability(context, symbol); … … 293 294 fixture.train(sequences); 294 295 295 List<Event <?>> context = new ArrayList<Event<?>>();296 context.add(Event.STARTEVENT); 297 context.add(new Event <String>("a"));298 299 Event <String> symbol = new Event<String>("b");296 List<Event> context = new ArrayList<Event>(); 297 context.add(Event.STARTEVENT); 298 context.add(new Event(new StringEventType("a"))); 299 300 Event symbol = new Event(new StringEventType("b")); 300 301 301 302 double result = fixture.getProbability(context, symbol); … … 314 315 fixture.train(sequences); 315 316 316 List<Event <?>> context = new ArrayList<Event<?>>();317 context.add(Event.STARTEVENT); 318 context.add(new Event <String>("a"));319 320 Event <String> symbol = new Event<String>("c");317 List<Event> context = new ArrayList<Event>(); 318 context.add(Event.STARTEVENT); 319 context.add(new Event(new StringEventType("a"))); 320 321 Event symbol = new Event(new StringEventType("c")); 321 322 322 323 double result = fixture.getProbability(context, symbol); … … 342 343 @Before 343 344 public void setUp() throws Exception { 344 List<Event <?>> sequence = new ArrayList<Event<?>>();345 sequence.add(new Event <String>("a"));346 sequence.add(new Event <String>("b"));347 sequence.add(new Event <String>("r"));348 sequence.add(new Event <String>("a"));349 sequence.add(new Event <String>("c"));350 sequence.add(new Event <String>("a"));351 sequence.add(new Event <String>("d"));352 sequence.add(new Event <String>("a"));353 sequence.add(new Event <String>("b"));354 sequence.add(new Event <String>("r"));355 sequence.add(new Event <String>("a"));356 357 sequences = new ArrayList<List< ? extends Event<?>>>();345 List<Event> sequence = new ArrayList<Event>(); 346 sequence.add(new Event(new StringEventType("a"))); 347 sequence.add(new Event(new StringEventType("b"))); 348 sequence.add(new Event(new StringEventType("r"))); 349 sequence.add(new Event(new StringEventType("a"))); 350 sequence.add(new Event(new StringEventType("c"))); 351 sequence.add(new Event(new StringEventType("a"))); 352 sequence.add(new Event(new StringEventType("d"))); 353 sequence.add(new Event(new StringEventType("a"))); 354 sequence.add(new Event(new StringEventType("b"))); 355 sequence.add(new Event(new StringEventType("r"))); 356 sequence.add(new Event(new StringEventType("a"))); 357 358 sequences = new ArrayList<List<Event>>(); 358 359 sequences.add(sequence); 359 360 } -
trunk/quest-core-usageprofiles-test/src/test/java/de/ugoe/cs/quest/usageprofiles/TrieBasedModelTest.java
r518 r548 11 11 import de.ugoe.cs.quest.usageprofiles.TrieBasedModel; 12 12 import de.ugoe.cs.quest.usageprofiles.TrieNode; 13 import de.ugoe.cs.quest.usageprofiles.mock.StringEventType; 13 14 14 15 import org.junit.*; … … 24 25 public class TrieBasedModelTest { 25 26 26 List<Event <?>> sequence;27 Collection<Event <?>> symbols;28 29 private void assertTrieStructure(Trie<Event <?>> trie, int numSequences) {30 TrieNode<Event <?>> root = trie.find(null);31 TrieNode<Event <?>> root_a = root.getChild(new Event<String>("a"));32 TrieNode<Event <?>> root_a_a = root_a.getChild(new Event<String>("a"));33 TrieNode<Event <?>> root_a_b = root_a.getChild(new Event<String>("b"));34 TrieNode<Event <?>> root_a_b_a = root_a_b35 .getChild(new Event <String>("a"));36 TrieNode<Event <?>> root_a_b_b = root_a_b37 .getChild(new Event <String>("b"));38 TrieNode<Event <?>> root_a_b_c = root_a_b39 .getChild(new Event <String>("c"));40 TrieNode<Event <?>> root_a_b_d = root_a_b41 .getChild(new Event <String>("d"));42 TrieNode<Event <?>> root_a_b_r = root_a_b43 .getChild(new Event <String>("r"));44 TrieNode<Event <?>> root_a_c = root_a.getChild(new Event<String>("c"));45 TrieNode<Event <?>> root_a_c_a = root_a_c46 .getChild(new Event <String>("a"));47 TrieNode<Event <?>> root_a_c_b = root_a_c48 .getChild(new Event <String>("b"));49 TrieNode<Event <?>> root_a_c_c = root_a_c50 .getChild(new Event <String>("c"));51 TrieNode<Event <?>> root_a_c_d = root_a_c52 .getChild(new Event <String>("d"));53 TrieNode<Event <?>> root_a_c_r = root_a_c54 .getChild(new Event <String>("r"));55 TrieNode<Event <?>> root_a_d = root_a.getChild(new Event<String>("d"));56 TrieNode<Event <?>> root_a_d_a = root_a_d57 .getChild(new Event <String>("a"));58 TrieNode<Event <?>> root_a_d_b = root_a_d59 .getChild(new Event <String>("b"));60 TrieNode<Event <?>> root_a_d_c = root_a_d61 .getChild(new Event <String>("c"));62 TrieNode<Event <?>> root_a_d_d = root_a_d63 .getChild(new Event <String>("d"));64 TrieNode<Event <?>> root_a_d_r = root_a_d65 .getChild(new Event <String>("r"));66 TrieNode<Event <?>> root_a_r = root_a.getChild(new Event<String>("r"));67 TrieNode<Event <?>> root_b = root.getChild(new Event<String>("b"));68 TrieNode<Event <?>> root_b_a = root_b.getChild(new Event<String>("a"));69 TrieNode<Event <?>> root_b_b = root_b.getChild(new Event<String>("b"));70 TrieNode<Event <?>> root_b_c = root_b.getChild(new Event<String>("c"));71 TrieNode<Event <?>> root_b_d = root_b.getChild(new Event<String>("d"));72 TrieNode<Event <?>> root_b_r = root_b.getChild(new Event<String>("r"));73 TrieNode<Event <?>> root_b_r_a = root_b_r74 .getChild(new Event <String>("a"));75 TrieNode<Event <?>> root_b_r_b = root_b_r76 .getChild(new Event <String>("b"));77 TrieNode<Event <?>> root_b_r_c = root_b_r78 .getChild(new Event <String>("c"));79 TrieNode<Event <?>> root_b_r_d = root_b_r80 .getChild(new Event <String>("d"));81 TrieNode<Event <?>> root_b_r_r = root_b_r82 .getChild(new Event <String>("r"));83 TrieNode<Event <?>> root_c = root.getChild(new Event<String>("c"));84 TrieNode<Event <?>> root_c_a = root_c.getChild(new Event<String>("a"));85 TrieNode<Event <?>> root_c_a_a = root_c_a86 .getChild(new Event <String>("a"));87 TrieNode<Event <?>> root_c_a_b = root_c_a88 .getChild(new Event <String>("b"));89 TrieNode<Event <?>> root_c_a_c = root_c_a90 .getChild(new Event <String>("c"));91 TrieNode<Event <?>> root_c_a_d = root_c_a92 .getChild(new Event <String>("d"));93 TrieNode<Event <?>> root_c_a_r = root_c_a94 .getChild(new Event <String>("r"));95 TrieNode<Event <?>> root_c_b = root_c.getChild(new Event<String>("b"));96 TrieNode<Event <?>> root_c_c = root_c.getChild(new Event<String>("c"));97 TrieNode<Event <?>> root_c_d = root_c.getChild(new Event<String>("d"));98 TrieNode<Event <?>> root_c_r = root_c.getChild(new Event<String>("r"));99 TrieNode<Event <?>> root_d = root.getChild(new Event<String>("d"));100 TrieNode<Event <?>> root_d_a = root_d.getChild(new Event<String>("a"));101 TrieNode<Event <?>> root_d_a_a = root_d_a102 .getChild(new Event <String>("a"));103 TrieNode<Event <?>> root_d_a_b = root_d_a104 .getChild(new Event <String>("b"));105 TrieNode<Event <?>> root_d_a_c = root_d_a106 .getChild(new Event <String>("c"));107 TrieNode<Event <?>> root_d_a_d = root_d_a108 .getChild(new Event <String>("d"));109 TrieNode<Event <?>> root_d_a_r = root_d_a110 .getChild(new Event <String>("r"));111 TrieNode<Event <?>> root_d_b = root_d.getChild(new Event<String>("b"));112 TrieNode<Event <?>> root_d_c = root_d.getChild(new Event<String>("c"));113 TrieNode<Event <?>> root_d_d = root_d.getChild(new Event<String>("d"));114 TrieNode<Event <?>> root_d_r = root_d.getChild(new Event<String>("r"));115 TrieNode<Event <?>> root_r = root.getChild(new Event<String>("r"));116 TrieNode<Event <?>> root_r_a = root_r.getChild(new Event<String>("a"));117 TrieNode<Event <?>> root_r_a_a = root_r_a118 .getChild(new Event <String>("a"));119 TrieNode<Event <?>> root_r_a_b = root_r_a120 .getChild(new Event <String>("b"));121 TrieNode<Event <?>> root_r_a_c = root_r_a122 .getChild(new Event <String>("c"));123 TrieNode<Event <?>> root_r_a_d = root_r_a124 .getChild(new Event <String>("d"));125 TrieNode<Event <?>> root_r_a_r = root_r_a126 .getChild(new Event <String>("r"));127 TrieNode<Event <?>> root_r_a_end = root_r_a.getChild(Event.ENDEVENT);128 TrieNode<Event <?>> root_r_b = root_r.getChild(new Event<String>("b"));129 TrieNode<Event <?>> root_r_c = root_r.getChild(new Event<String>("c"));130 TrieNode<Event <?>> root_r_d = root_r.getChild(new Event<String>("d"));131 TrieNode<Event <?>> root_r_r = root_r.getChild(new Event<String>("r"));132 TrieNode<Event <?>> root_start = root.getChild(Event.STARTEVENT);133 TrieNode<Event <?>> root_start_a = root_start134 .getChild(new Event <String>("a"));135 TrieNode<Event <?>> root_start_a_a = root_start_a136 .getChild(new Event <String>("a"));137 TrieNode<Event <?>> root_start_a_b = root_start_a138 .getChild(new Event <String>("b"));139 TrieNode<Event <?>> root_start_a_c = root_start_a140 .getChild(new Event <String>("c"));141 TrieNode<Event <?>> root_start_a_d = root_start_a142 .getChild(new Event <String>("d"));143 TrieNode<Event <?>> root_start_a_r = root_start_a144 .getChild(new Event <String>("r"));145 TrieNode<Event <?>> root_start_b = root_start146 .getChild(new Event <String>("b"));147 TrieNode<Event <?>> root_start_c = root_start148 .getChild(new Event <String>("c"));149 TrieNode<Event <?>> root_start_d = root_start150 .getChild(new Event <String>("d"));151 TrieNode<Event <?>> root_start_r = root_start152 .getChild(new Event <String>("r"));27 List<Event> sequence; 28 Collection<Event> symbols; 29 30 private void assertTrieStructure(Trie<Event> trie, int numSequences) { 31 TrieNode<Event> root = trie.find(null); 32 TrieNode<Event> root_a = root.getChild(new Event(new StringEventType("a"))); 33 TrieNode<Event> root_a_a = root_a.getChild(new Event(new StringEventType("a"))); 34 TrieNode<Event> root_a_b = root_a.getChild(new Event(new StringEventType("b"))); 35 TrieNode<Event> root_a_b_a = root_a_b 36 .getChild(new Event(new StringEventType("a"))); 37 TrieNode<Event> root_a_b_b = root_a_b 38 .getChild(new Event(new StringEventType("b"))); 39 TrieNode<Event> root_a_b_c = root_a_b 40 .getChild(new Event(new StringEventType("c"))); 41 TrieNode<Event> root_a_b_d = root_a_b 42 .getChild(new Event(new StringEventType("d"))); 43 TrieNode<Event> root_a_b_r = root_a_b 44 .getChild(new Event(new StringEventType("r"))); 45 TrieNode<Event> root_a_c = root_a.getChild(new Event(new StringEventType("c"))); 46 TrieNode<Event> root_a_c_a = root_a_c 47 .getChild(new Event(new StringEventType("a"))); 48 TrieNode<Event> root_a_c_b = root_a_c 49 .getChild(new Event(new StringEventType("b"))); 50 TrieNode<Event> root_a_c_c = root_a_c 51 .getChild(new Event(new StringEventType("c"))); 52 TrieNode<Event> root_a_c_d = root_a_c 53 .getChild(new Event(new StringEventType("d"))); 54 TrieNode<Event> root_a_c_r = root_a_c 55 .getChild(new Event(new StringEventType("r"))); 56 TrieNode<Event> root_a_d = root_a.getChild(new Event(new StringEventType("d"))); 57 TrieNode<Event> root_a_d_a = root_a_d 58 .getChild(new Event(new StringEventType("a"))); 59 TrieNode<Event> root_a_d_b = root_a_d 60 .getChild(new Event(new StringEventType("b"))); 61 TrieNode<Event> root_a_d_c = root_a_d 62 .getChild(new Event(new StringEventType("c"))); 63 TrieNode<Event> root_a_d_d = root_a_d 64 .getChild(new Event(new StringEventType("d"))); 65 TrieNode<Event> root_a_d_r = root_a_d 66 .getChild(new Event(new StringEventType("r"))); 67 TrieNode<Event> root_a_r = root_a.getChild(new Event(new StringEventType("r"))); 68 TrieNode<Event> root_b = root.getChild(new Event(new StringEventType("b"))); 69 TrieNode<Event> root_b_a = root_b.getChild(new Event(new StringEventType("a"))); 70 TrieNode<Event> root_b_b = root_b.getChild(new Event(new StringEventType("b"))); 71 TrieNode<Event> root_b_c = root_b.getChild(new Event(new StringEventType("c"))); 72 TrieNode<Event> root_b_d = root_b.getChild(new Event(new StringEventType("d"))); 73 TrieNode<Event> root_b_r = root_b.getChild(new Event(new StringEventType("r"))); 74 TrieNode<Event> root_b_r_a = root_b_r 75 .getChild(new Event(new StringEventType("a"))); 76 TrieNode<Event> root_b_r_b = root_b_r 77 .getChild(new Event(new StringEventType("b"))); 78 TrieNode<Event> root_b_r_c = root_b_r 79 .getChild(new Event(new StringEventType("c"))); 80 TrieNode<Event> root_b_r_d = root_b_r 81 .getChild(new Event(new StringEventType("d"))); 82 TrieNode<Event> root_b_r_r = root_b_r 83 .getChild(new Event(new StringEventType("r"))); 84 TrieNode<Event> root_c = root.getChild(new Event(new StringEventType("c"))); 85 TrieNode<Event> root_c_a = root_c.getChild(new Event(new StringEventType("a"))); 86 TrieNode<Event> root_c_a_a = root_c_a 87 .getChild(new Event(new StringEventType("a"))); 88 TrieNode<Event> root_c_a_b = root_c_a 89 .getChild(new Event(new StringEventType("b"))); 90 TrieNode<Event> root_c_a_c = root_c_a 91 .getChild(new Event(new StringEventType("c"))); 92 TrieNode<Event> root_c_a_d = root_c_a 93 .getChild(new Event(new StringEventType("d"))); 94 TrieNode<Event> root_c_a_r = root_c_a 95 .getChild(new Event(new StringEventType("r"))); 96 TrieNode<Event> root_c_b = root_c.getChild(new Event(new StringEventType("b"))); 97 TrieNode<Event> root_c_c = root_c.getChild(new Event(new StringEventType("c"))); 98 TrieNode<Event> root_c_d = root_c.getChild(new Event(new StringEventType("d"))); 99 TrieNode<Event> root_c_r = root_c.getChild(new Event(new StringEventType("r"))); 100 TrieNode<Event> root_d = root.getChild(new Event(new StringEventType("d"))); 101 TrieNode<Event> root_d_a = root_d.getChild(new Event(new StringEventType("a"))); 102 TrieNode<Event> root_d_a_a = root_d_a 103 .getChild(new Event(new StringEventType("a"))); 104 TrieNode<Event> root_d_a_b = root_d_a 105 .getChild(new Event(new StringEventType("b"))); 106 TrieNode<Event> root_d_a_c = root_d_a 107 .getChild(new Event(new StringEventType("c"))); 108 TrieNode<Event> root_d_a_d = root_d_a 109 .getChild(new Event(new StringEventType("d"))); 110 TrieNode<Event> root_d_a_r = root_d_a 111 .getChild(new Event(new StringEventType("r"))); 112 TrieNode<Event> root_d_b = root_d.getChild(new Event(new StringEventType("b"))); 113 TrieNode<Event> root_d_c = root_d.getChild(new Event(new StringEventType("c"))); 114 TrieNode<Event> root_d_d = root_d.getChild(new Event(new StringEventType("d"))); 115 TrieNode<Event> root_d_r = root_d.getChild(new Event(new StringEventType("r"))); 116 TrieNode<Event> root_r = root.getChild(new Event(new StringEventType("r"))); 117 TrieNode<Event> root_r_a = root_r.getChild(new Event(new StringEventType("a"))); 118 TrieNode<Event> root_r_a_a = root_r_a 119 .getChild(new Event(new StringEventType("a"))); 120 TrieNode<Event> root_r_a_b = root_r_a 121 .getChild(new Event(new StringEventType("b"))); 122 TrieNode<Event> root_r_a_c = root_r_a 123 .getChild(new Event(new StringEventType("c"))); 124 TrieNode<Event> root_r_a_d = root_r_a 125 .getChild(new Event(new StringEventType("d"))); 126 TrieNode<Event> root_r_a_r = root_r_a 127 .getChild(new Event(new StringEventType("r"))); 128 TrieNode<Event> root_r_a_end = root_r_a.getChild(Event.ENDEVENT); 129 TrieNode<Event> root_r_b = root_r.getChild(new Event(new StringEventType("b"))); 130 TrieNode<Event> root_r_c = root_r.getChild(new Event(new StringEventType("c"))); 131 TrieNode<Event> root_r_d = root_r.getChild(new Event(new StringEventType("d"))); 132 TrieNode<Event> root_r_r = root_r.getChild(new Event(new StringEventType("r"))); 133 TrieNode<Event> root_start = root.getChild(Event.STARTEVENT); 134 TrieNode<Event> root_start_a = root_start 135 .getChild(new Event(new StringEventType("a"))); 136 TrieNode<Event> root_start_a_a = root_start_a 137 .getChild(new Event(new StringEventType("a"))); 138 TrieNode<Event> root_start_a_b = root_start_a 139 .getChild(new Event(new StringEventType("b"))); 140 TrieNode<Event> root_start_a_c = root_start_a 141 .getChild(new Event(new StringEventType("c"))); 142 TrieNode<Event> root_start_a_d = root_start_a 143 .getChild(new Event(new StringEventType("d"))); 144 TrieNode<Event> root_start_a_r = root_start_a 145 .getChild(new Event(new StringEventType("r"))); 146 TrieNode<Event> root_start_b = root_start 147 .getChild(new Event(new StringEventType("b"))); 148 TrieNode<Event> root_start_c = root_start 149 .getChild(new Event(new StringEventType("c"))); 150 TrieNode<Event> root_start_d = root_start 151 .getChild(new Event(new StringEventType("d"))); 152 TrieNode<Event> root_start_r = root_start 153 .getChild(new Event(new StringEventType("r"))); 153 154 154 155 assertEquals(numSequences * 5, root_a.getCount()); … … 287 288 MockTrieBasedModel fixture = new MockTrieBasedModel(markovOrder, 288 289 new Random()); 289 Collection<List< ? extends Event<?>>> sequences = new ArrayList<List<? extends Event<?>>>();290 Collection<List<Event>> sequences = new ArrayList<List<Event>>(); 290 291 sequences.add(sequence); 291 292 fixture.train(sequences); 292 293 int length = 2; 293 294 294 Collection<List<Event <?>>> expected = new HashSet<List<Event<?>>>();295 ArrayList<Event <?>> list;296 list = new ArrayList<Event <?>>();297 list.add(new Event <String>("a"));295 Collection<List<Event>> expected = new HashSet<List<Event>>(); 296 ArrayList<Event> list; 297 list = new ArrayList<Event>(); 298 list.add(new Event(new StringEventType("a"))); 298 299 list.add(Event.ENDEVENT); 299 300 expected.add(list); 300 list = new ArrayList<Event <?>>();301 list.add(new Event <String>("a"));302 list.add(new Event <String>("b"));303 expected.add(list); 304 list = new ArrayList<Event <?>>();305 list.add(new Event <String>("a"));306 list.add(new Event <String>("c"));307 expected.add(list); 308 list = new ArrayList<Event <?>>();309 list.add(new Event <String>("a"));310 list.add(new Event <String>("d"));311 expected.add(list); 312 list = new ArrayList<Event <?>>();313 list.add(new Event <String>("b"));314 list.add(new Event <String>("r"));315 expected.add(list); 316 list = new ArrayList<Event <?>>();317 list.add(new Event <String>("c"));318 list.add(new Event <String>("a"));319 expected.add(list); 320 list = new ArrayList<Event <?>>();321 list.add(new Event <String>("d"));322 list.add(new Event <String>("a"));323 expected.add(list); 324 list = new ArrayList<Event <?>>();325 list.add(new Event <String>("r"));326 list.add(new Event <String>("a"));327 expected.add(list); 328 list = new ArrayList<Event <?>>();301 list = new ArrayList<Event>(); 302 list.add(new Event(new StringEventType("a"))); 303 list.add(new Event(new StringEventType("b"))); 304 expected.add(list); 305 list = new ArrayList<Event>(); 306 list.add(new Event(new StringEventType("a"))); 307 list.add(new Event(new StringEventType("c"))); 308 expected.add(list); 309 list = new ArrayList<Event>(); 310 list.add(new Event(new StringEventType("a"))); 311 list.add(new Event(new StringEventType("d"))); 312 expected.add(list); 313 list = new ArrayList<Event>(); 314 list.add(new Event(new StringEventType("b"))); 315 list.add(new Event(new StringEventType("r"))); 316 expected.add(list); 317 list = new ArrayList<Event>(); 318 list.add(new Event(new StringEventType("c"))); 319 list.add(new Event(new StringEventType("a"))); 320 expected.add(list); 321 list = new ArrayList<Event>(); 322 list.add(new Event(new StringEventType("d"))); 323 list.add(new Event(new StringEventType("a"))); 324 expected.add(list); 325 list = new ArrayList<Event>(); 326 list.add(new Event(new StringEventType("r"))); 327 list.add(new Event(new StringEventType("a"))); 328 expected.add(list); 329 list = new ArrayList<Event>(); 329 330 list.add(Event.STARTEVENT); 330 list.add(new Event <String>("a"));331 expected.add(list); 332 333 Collection<List< ? extends Event<?>>> result = fixture331 list.add(new Event(new StringEventType("a"))); 332 expected.add(list); 333 334 Collection<List<Event>> result = fixture 334 335 .generateSequences(length); 335 336 … … 342 343 MockTrieBasedModel fixture = new MockTrieBasedModel(markovOrder, 343 344 new Random()); 344 Collection<List< ? extends Event<?>>> sequences = new ArrayList<List<? extends Event<?>>>();345 Collection<List<Event>> sequences = new ArrayList<List<Event>>(); 345 346 sequences.add(sequence); 346 347 fixture.train(sequences); 347 348 int length = 3; 348 349 349 Collection<List<Event <?>>> expected = new HashSet<List<Event<?>>>();350 ArrayList<Event <?>> list;351 list = new ArrayList<Event <?>>();350 Collection<List<Event>> expected = new HashSet<List<Event>>(); 351 ArrayList<Event> list; 352 list = new ArrayList<Event>(); 352 353 list.add(Event.STARTEVENT); 353 list.add(new Event <String>("a"));354 list.add(new Event(new StringEventType("a"))); 354 355 list.add(Event.ENDEVENT); 355 356 expected.add(list); 356 list = new ArrayList<Event <?>>();357 list = new ArrayList<Event>(); 357 358 list.add(Event.STARTEVENT); 358 list.add(new Event <String>("a"));359 list.add(new Event <String>("b"));360 expected.add(list); 361 list = new ArrayList<Event <?>>();359 list.add(new Event(new StringEventType("a"))); 360 list.add(new Event(new StringEventType("b"))); 361 expected.add(list); 362 list = new ArrayList<Event>(); 362 363 list.add(Event.STARTEVENT); 363 list.add(new Event <String>("a"));364 list.add(new Event <String>("c"));365 expected.add(list); 366 list = new ArrayList<Event <?>>();364 list.add(new Event(new StringEventType("a"))); 365 list.add(new Event(new StringEventType("c"))); 366 expected.add(list); 367 list = new ArrayList<Event>(); 367 368 list.add(Event.STARTEVENT); 368 list.add(new Event <String>("a"));369 list.add(new Event <String>("d"));370 expected.add(list); 371 372 Collection<List< ? extends Event<?>>> result = fixture369 list.add(new Event(new StringEventType("a"))); 370 list.add(new Event(new StringEventType("d"))); 371 expected.add(list); 372 373 Collection<List<Event>> result = fixture 373 374 .generateSequences(length, true); 374 375 … … 381 382 MockTrieBasedModel fixture = new MockTrieBasedModel(markovOrder, 382 383 new Random()); 383 Collection<List< ? extends Event<?>>> sequences = new ArrayList<List<? extends Event<?>>>();384 Collection<List<Event>> sequences = new ArrayList<List<Event>>(); 384 385 sequences.add(sequence); 385 386 fixture.train(sequences); … … 394 395 MockTrieBasedModel fixture = new MockTrieBasedModel(markovOrder, 395 396 new Random()); 396 Collection<List< ? extends Event<?>>> sequences = new ArrayList<List<? extends Event<?>>>();397 Collection<List<Event>> sequences = new ArrayList<List<Event>>(); 397 398 sequences.add(sequence); 398 399 fixture.train(sequences); 399 400 int length = 5; 400 401 401 Collection<List<Event <?>>> expected = new HashSet<List<Event<?>>>();402 ArrayList<Event <?>> list;403 list = new ArrayList<Event <?>>();402 Collection<List<Event>> expected = new HashSet<List<Event>>(); 403 ArrayList<Event> list; 404 list = new ArrayList<Event>(); 404 405 list.add(Event.STARTEVENT); 405 list.add(new Event <String>("a"));406 list.add(new Event <String>("c"));407 list.add(new Event <String>("a"));406 list.add(new Event(new StringEventType("a"))); 407 list.add(new Event(new StringEventType("c"))); 408 list.add(new Event(new StringEventType("a"))); 408 409 list.add(Event.ENDEVENT); 409 410 expected.add(list); 410 list = new ArrayList<Event <?>>();411 list = new ArrayList<Event>(); 411 412 list.add(Event.STARTEVENT); 412 list.add(new Event <String>("a"));413 list.add(new Event <String>("d"));414 list.add(new Event <String>("a"));413 list.add(new Event(new StringEventType("a"))); 414 list.add(new Event(new StringEventType("d"))); 415 list.add(new Event(new StringEventType("a"))); 415 416 list.add(Event.ENDEVENT); 416 417 expected.add(list); 417 418 418 Collection<List< ? extends Event<?>>> result = fixture419 Collection<List<Event>> result = fixture 419 420 .generateValidSequences(length); 420 421 … … 427 428 MockTrieBasedModel fixture = new MockTrieBasedModel(markovOrder, 428 429 new Random()); 429 Collection<List< ? extends Event<?>>> sequences = new ArrayList<List<? extends Event<?>>>();430 Collection<List<Event>> sequences = new ArrayList<List<Event>>(); 430 431 sequences.add(sequence); 431 432 fixture.train(sequences); … … 440 441 MockTrieBasedModel fixture = new MockTrieBasedModel(markovOrder, 441 442 new Random()); 442 Collection<List< ? extends Event<?>>> sequences = new ArrayList<List<? extends Event<?>>>();443 sequences.add(sequence); 444 445 fixture.train(sequences); 446 447 Collection< ? extends Event<?>> result = fixture.getEvents();443 Collection<List<Event>> sequences = new ArrayList<List<Event>>(); 444 sequences.add(sequence); 445 446 fixture.train(sequences); 447 448 Collection<Event> result = fixture.getEvents(); 448 449 449 450 assertCollectionContent(symbols, result); … … 456 457 new Random()); 457 458 458 Collection< ? extends Event<?>> result = fixture.getEvents();459 460 assertCollectionContent(new HashSet<Event <?>>(), result);459 Collection<Event> result = fixture.getEvents(); 460 461 assertCollectionContent(new HashSet<Event>(), result); 461 462 } 462 463 … … 466 467 MockTrieBasedModel fixture = new MockTrieBasedModel(markovOrder, 467 468 new Random()); 468 Collection<List< ? extends Event<?>>> sequences = new ArrayList<List<? extends Event<?>>>();469 Collection<List<Event>> sequences = new ArrayList<List<Event>>(); 469 470 sequences.add(sequence); 470 471 … … 493 494 MockTrieBasedModel fixture = new MockTrieBasedModel(markovOrder, 494 495 new Random()); 495 Collection<List< ? extends Event<?>>> sequences = new ArrayList<List<? extends Event<?>>>();496 Collection<List<Event>> sequences = new ArrayList<List<Event>>(); 496 497 sequences.add(sequence); 497 498 fixture.train(sequences); … … 518 519 MockTrieBasedModel fixture = new MockTrieBasedModel(markovOrder, 519 520 new Random()); 520 Collection<List< ? extends Event<?>>> sequences = new ArrayList<List<? extends Event<?>>>();521 Collection<List<Event>> sequences = new ArrayList<List<Event>>(); 521 522 sequences.add(sequence); 522 523 fixture.train(sequences); … … 543 544 MockTrieBasedModel fixture = new MockTrieBasedModel(markovOrder, 544 545 new Random()); 545 Collection<List< ? extends Event<?>>> sequences = new ArrayList<List<? extends Event<?>>>();546 Collection<List<Event>> sequences = new ArrayList<List<Event>>(); 546 547 sequences.add(sequence); 547 548 … … 558 559 MockTrieBasedModel fixture = new MockTrieBasedModel(markovOrder, 559 560 new Random()); 560 Collection<List< ? extends Event<?>>> sequences = new ArrayList<List<? extends Event<?>>>();561 Collection<List<Event>> sequences = new ArrayList<List<Event>>(); 561 562 sequences.add(sequence); 562 563 sequences.add(sequence); … … 574 575 MockTrieBasedModel fixture = new MockTrieBasedModel(markovOrder, 575 576 new Random()); 576 Collection<List< ? extends Event<?>>> sequences = null;577 Collection<List<Event>> sequences = null; 577 578 578 579 fixture.train(sequences); … … 584 585 MockTrieBasedModel fixture = new MockTrieBasedModel(markovOrder, 585 586 new Random()); 586 Collection<List< ? extends Event<?>>> sequences = new ArrayList<List<? extends Event<?>>>();587 Collection<List<Event>> sequences = new ArrayList<List<Event>>(); 587 588 sequences.add(sequence); 588 589 fixture.train(sequences); … … 599 600 MockTrieBasedModel fixture = new MockTrieBasedModel(markovOrder, 600 601 new Random()); 601 Collection<List< ? extends Event<?>>> sequences = null;602 Collection<List<Event>> sequences = null; 602 603 fixture.trie = null; 603 604 … … 607 608 @Before 608 609 public void setUp() throws Exception { 609 sequence = new ArrayList<Event <?>>();610 sequence.add(new Event <String>("a"));611 sequence.add(new Event <String>("b"));612 sequence.add(new Event <String>("r"));613 sequence.add(new Event <String>("a"));614 sequence.add(new Event <String>("c"));615 sequence.add(new Event <String>("a"));616 sequence.add(new Event <String>("d"));617 sequence.add(new Event <String>("a"));618 sequence.add(new Event <String>("b"));619 sequence.add(new Event <String>("r"));620 sequence.add(new Event <String>("a"));621 622 symbols = new HashSet<Event <?>>();623 symbols.add(new Event <String>("a"));624 symbols.add(new Event <String>("b"));625 symbols.add(new Event <String>("c"));626 symbols.add(new Event <String>("d"));627 symbols.add(new Event <String>("r"));610 sequence = new ArrayList<Event>(); 611 sequence.add(new Event(new StringEventType("a"))); 612 sequence.add(new Event(new StringEventType("b"))); 613 sequence.add(new Event(new StringEventType("r"))); 614 sequence.add(new Event(new StringEventType("a"))); 615 sequence.add(new Event(new StringEventType("c"))); 616 sequence.add(new Event(new StringEventType("a"))); 617 sequence.add(new Event(new StringEventType("d"))); 618 sequence.add(new Event(new StringEventType("a"))); 619 sequence.add(new Event(new StringEventType("b"))); 620 sequence.add(new Event(new StringEventType("r"))); 621 sequence.add(new Event(new StringEventType("a"))); 622 623 symbols = new HashSet<Event>(); 624 symbols.add(new Event(new StringEventType("a"))); 625 symbols.add(new Event(new StringEventType("b"))); 626 symbols.add(new Event(new StringEventType("c"))); 627 symbols.add(new Event(new StringEventType("d"))); 628 symbols.add(new Event(new StringEventType("r"))); 628 629 symbols.add(Event.STARTEVENT); 629 630 symbols.add(Event.ENDEVENT);
Note: See TracChangeset
for help on using the changeset viewer.