Changeset 1693
- Timestamp:
- 08/24/14 21:12:44 (10 years ago)
- Location:
- branches
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/autoquest-core-tasktrees-alignment-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignmentTest.java
r1654 r1693 17 17 import org.junit.Test; 18 18 19 import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.Match; 20 import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.NumberSequence; 21 19 22 /** 20 23 * @author Patrick Harms … … 22 25 public class SequenceForTaskDetectionRuleAlignmentTest extends AbstractTemporalRelationshipTC { 23 26 27 28 @Test 29 public void test_MatchAsSequences() { 30 Match m1 = new Match(); 31 int[] pat1 = new int[]{2,1,3,-1,3,5,4,8,3,1}; 32 int[] pat2 = new int[]{1,2,3, 4,3,4,5,3,3,-1}; 33 NumberSequence ns1 = new NumberSequence(10); 34 NumberSequence ns2 = new NumberSequence(10); 35 ns1.setSequence(pat1); 36 ns2.setSequence(pat2); 37 m1.setFirstSequence(ns1); 38 m1.setSecondSequence(ns1); 39 40 41 } 42 24 43 /** 25 44 * -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/Match.java
r1657 r1693 11 11 private LinkedList<MatchOccurence> occurences; 12 12 13 Match() {13 public Match() { 14 14 matchseqs = new ArrayList<NumberSequence>(2); 15 15 occurences = new LinkedList<MatchOccurence>(); -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NumberSequence.java
r1665 r1693 45 45 46 46 //Recursive check if sequence contains pattern at position i 47 private boolean matches(int i, int[] p1, int[] p2 ,int ip1,int ip2,boolean jumped1,boolean jumped2) { 47 private boolean matches(int i, 48 int[] p1, 49 int[] p2 , 50 int ip1, 51 int ip2, 52 boolean jumped1, //True if there was a gap in Sequence 1 of the pattern 53 boolean jumped2, //True if there was a gap in Sequence 2 of the pattern 54 boolean hadSelection, //True if the last match was a selection 55 boolean matchseq1, 56 boolean matchseq2) { 48 57 49 58 if(p1.length==ip1) { … … 56 65 return false; 57 66 } 58 if((p1[ip1]==sequence[i]||p2[ip2]==sequence[i]) && jumped1) { 59 return matches(i+1,p1,p2,ip1+1,ip2+2,false,false); 67 68 boolean foundselection=(!(p1[ip1] == p2[ip2])&&!(p1[ip1]==-1||p2[ip2]==-1)); 69 boolean matchInFirstPattern = (p1[ip1]==sequence[i]); 70 boolean matchInSecondPattern = (p2[ip2]==sequence[i]); 71 72 if(foundselection && hadSelection) { 73 if((matchInFirstPattern && matchseq1) || (matchInSecondPattern && matchseq2)){ 74 if(jumped1) { 75 return matches(i+1,p1,p2,ip1+1,ip2+2,false,false,foundselection,matchInFirstPattern,matchInSecondPattern); 76 } 77 if(jumped2) { 78 return matches(i+1,p1,p2,ip1+2,ip2+1,false,false,foundselection,matchInFirstPattern,matchInSecondPattern); 79 } 80 return matches(i+1,p1,p2,ip1+1,ip2+1,false,false,foundselection,matchInFirstPattern,matchInSecondPattern); 81 } 82 else { 83 return false; 84 } 60 85 } 61 if((p1[ip1]==sequence[i]||p2[ip2]==sequence[i]) && jumped2) { 62 return matches(i+1,p1,p2,ip1+2,ip2+1,false,false); 86 87 if((matchInFirstPattern||matchInSecondPattern) && jumped1) { 88 return matches(i+1,p1,p2,ip1+1,ip2+2,false,false,foundselection,matchInFirstPattern,matchInSecondPattern); 63 89 } 64 if(p1[ip1]==sequence[i]||p2[ip2]==sequence[i]) { 65 return matches(i+1,p1,p2,ip1+1,ip2+1,false,false); 90 if((matchInFirstPattern||matchInSecondPattern) && jumped2) { 91 return matches(i+1,p1,p2,ip1+2,ip2+1,false,false,foundselection,matchInFirstPattern,matchInSecondPattern); 92 } 93 if(matchInFirstPattern||matchInSecondPattern) { 94 return matches(i+1,p1,p2,ip1+1,ip2+1,false,false,foundselection,matchInFirstPattern,matchInSecondPattern); 66 95 } 67 96 if(p1[ip1]==-1) { 68 return matches(i,p1,p2,ip1+1,ip2,true,false );97 return matches(i,p1,p2,ip1+1,ip2,true,false,false,false,false); 69 98 } 70 99 if(p2[ip2]==-1) { 71 return matches(i,p1,p2,ip1,ip2+1,false,true );100 return matches(i,p1,p2,ip1,ip2+1,false,true,false,false,false); 72 101 } 73 102 … … 83 112 84 113 while (i < sequence.length ) { 85 if(matches(i,pat1,pat2,0,0,false,false )) {114 if(matches(i,pat1,pat2,0,0,false,false,false,false,false)) { 86 115 result.add(i); 87 116 } -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/matrix/ObjectDistanceSubstitionMatrix.java
r1692 r1693 105 105 } 106 106 107 //TODO: Calculate distance here108 107 private float distanceBetweenTasks(ITask task1, ITask task2) { 109 108 return 0; -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/RuleUtils.java
r1692 r1693 24 24 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequence; 25 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ISequenceInstance; 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship; 26 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; 27 28 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; … … 102 103 * 103 104 * @return the replacement for the range 105 * @throws 104 106 */ 105 107 static ISequenceInstance createNewSubSequenceInRange( 106 108 ITaskInstanceList parent, int startIndex, int endIndex, 107 ISequence model, ITaskFactory taskFactory, ITaskBuilder taskBuilder) {109 ISequence model, ITaskFactory taskFactory, ITaskBuilder taskBuilder) { 108 110 ISequenceInstance subsequence = taskFactory 109 111 .createNewTaskInstance(model); 110 112 111 //for (int i=0; i<subsequence.getSequence().getChildren().size();i++) { 112 // System.out.println(subsequence.getSequence().getChildren().get(i)); 113 //} 114 //System.out.println(); 113 // TODO: Debug output 114 System.out.println("PRINTING MODEL: "); 115 for (int i = 0; i < subsequence.getSequence().getChildren().size(); i++) { 116 System.out.println(subsequence.getSequence().getChildren().get(i)); 117 118 if (subsequence.getSequence().getChildren().get(i).getType() == "selection") { 119 for (int j = 0; j < ((ISelection) subsequence.getSequence().getChildren().get(i)) 120 .getChildren().size(); j++) { 121 if(((IStructuringTemporalRelationship) subsequence.getSequence().getChildren().get(i)).getChildren().get(j).getType() =="sequence") 122 { 123 ISequence foo = (ISequence) ((ISelection) (subsequence.getSequence().getChildren().get(i))).getChildren().get(j); 124 System.out.println("\t" + foo); 125 for(int k=0; k< foo.getChildren().size();k++) { 126 System.out.println("\t\t" +foo.getChildren().get(k)); 127 } 128 System.out.println(); 129 } 130 else{ 131 System.out.println("\t" 132 + ((ISelection) subsequence.getSequence().getChildren().get(i)) 133 .getChildren().get(j)); 134 } 135 136 } 137 } 138 139 } 140 System.out.println(); 141 115 142 //TODO: This is dirty! 116 143 missedOptionals=0; … … 127 154 128 155 if(((IMarkingTemporalRelationship) tempTask).getMarkedTask() == parent.get(startIndex).getTask()) { 129 //System.out.println("Adding OptionalInstance " + parent.get(startIndex) + " to " + tempTask.getType());156 System.out.println("Adding OptionalInstance " + parent.get(startIndex) + " to " + tempTask.getType()); 130 157 IOptionalInstance optional = taskFactory.createNewTaskInstance((IOptional) tempTask); 131 158 taskBuilder.setChild(optional, parent.get(startIndex)); … … 141 168 } 142 169 } else if (tempTask.getType() == "selection") { 143 //System.out.println("Adding SelectionInstance " + parent.get(startIndex) + " to " + tempTask.getType());170 144 171 ISelectionInstance selection = taskFactory.createNewTaskInstance((ISelection) tempTask); 145 taskBuilder.setChild(selection, parent.get(startIndex) ); 172 ISelection tmpSel = (ISelection)tempTask; 173 if(tmpSel.getChildren().get(0).getType() == "sequence" && tmpSel.getChildren().get(1).getType()=="sequence") { 174 System.out.println("Adding SequenceInstance " + parent.get(startIndex) + " to " + tempTask); 175 ISequenceInstance selseq = null; 176 System.out.println("IDS: " + parent.get(startIndex).getTask().getId() + " " +((ISequence)tmpSel.getChildren().get(0)).getChildren().get(0).getId()); 177 System.out.println("IDS: " + parent.get(startIndex).getTask().getId() + " " +((ISequence)tmpSel.getChildren().get(1)).getChildren().get(0).getId()); 178 if(parent.get(startIndex).getTask().getId() == ((ISequence)tmpSel.getChildren().get(0)).getChildren().get(0).getId()) { 179 selseq = taskFactory.createNewTaskInstance((ISequence) tmpSel.getChildren().get(0)); 180 } 181 else if(parent.get(startIndex).getTask().getId() == ((ISequence)tmpSel.getChildren().get(1)).getChildren().get(0).getId()) { 182 selseq = taskFactory.createNewTaskInstance((ISequence) tmpSel.getChildren().get(1)); 183 } 184 else { 185 //throw new Exception("Error while creating subsequence of a selection"); 186 187 System.out.println("Error while creating subsequence of a selection"); 188 } 189 190 for (int k=0;k<selseq.getSequence().getChildren().size();k++) { 191 taskBuilder.addChild(selseq,parent.get(startIndex)); 192 taskBuilder.removeTaskInstance(parent, startIndex); 193 i++; 194 } 195 taskBuilder.setChild(selection, selseq); 196 } 197 else 198 { 199 System.out.println("Adding SelectionInstance " + parent.get(startIndex) + " to " + tempTask); 200 taskBuilder.setChild(selection, parent.get(startIndex)); 201 } 146 202 taskBuilder.addChild(subsequence,selection); 147 203 148 204 } else if (tempTask.getType() == "sequence") { 149 //ISequenceInstance sequence = taskFactory.createNewTaskInstance((ISequence) tempTask); 150 //taskBuilder.addChild(sequence, parent.get(i)); 151 //taskBuilder.addChild(subsequence,sequence); 205 System.out.println("Adding SequenceInstance " + parent.get(startIndex) + " to " + tempTask); 206 ISequenceInstance sequence = taskFactory.createNewTaskInstance((ISequence) tempTask); 207 taskBuilder.addChild(sequence, parent.get(i)); 208 taskBuilder.addChild(subsequence,sequence); 209 //taskBuilder.addChild(subsequence, parent.get(startIndex)); 210 } else if (tempTask.getType() == "iteration") { 211 System.out.println("Adding IterationInstance " + parent.get(startIndex) + " to " + tempTask); 152 212 taskBuilder.addChild(subsequence, parent.get(startIndex)); 153 } else if (tempTask.getType() == "iteration") {154 //IIterationInstance iteration = taskFactory.createNewTaskInstance((IIteration) tempTask);155 //taskBuilder.addChild(iteration, parent.get(startIndex));156 //taskBuilder.addChild(subsequence, iteration);157 taskBuilder.addChild(subsequence, parent.get(startIndex));158 //System.out.println("Adding IterationInstance " + parent.get(startIndex) + " to " + tempTask.getType());159 213 } else { 160 //System.out.println("Adding EventInstance " + parent.get(startIndex) + " to " + tempTask.getType());214 System.out.println("Adding EventInstance " + parent.get(startIndex) + " to " + tempTask); 161 215 taskBuilder.addChild(subsequence, parent.get(startIndex)); 162 216 } -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignment.java
r1692 r1693 68 68 class SequenceForTaskDetectionRuleAlignment implements ISessionScopeRule { 69 69 70 71 70 private int iteration = 0; 72 71 /** … … 92 91 */ 93 92 private TaskHandlingStrategy preparationTaskHandlingStrategy; 94 95 93 96 94 /** … … 139 137 public RuleApplicationResult apply(List<IUserSession> sessions) { 140 138 RuleApplicationData appData = new RuleApplicationData(sessions); 141 139 142 140 harmonizeEventTaskInstancesModel(appData); 143 141 do { 144 142 iteration++; 145 143 146 144 appData.detectedAndReplacedTasks = false; 147 appData.getStopWatch().start("whole loop"); 145 appData.getStopWatch().start("whole loop"); 148 146 detectAndReplaceIterations(appData); 149 appData.getStopWatch().start("task replacement"); 147 appData.getStopWatch().start("task replacement"); 150 148 detectAndReplaceTasks(appData); // 151 appData.getStopWatch().stop("task replacement"); 149 appData.getStopWatch().stop("task replacement"); 152 150 appData.getStopWatch().stop("whole loop"); 153 appData.getStopWatch().dumpStatistics(System.out); 151 appData.getStopWatch().dumpStatistics(System.out); 154 152 appData.getStopWatch().reset(); 155 153 … … 181 179 templist.getSequence()[j] = taskInstance.getTask().getId(); 182 180 } 183 //System.out.println();184 181 // Each NumberSequence is identified by its id, beginning to count 185 182 // at zero … … 207 204 "harmonizing task model of event task instances"); 208 205 appData.getStopWatch().start("harmonizing event tasks"); 209 SymbolMap<ITaskInstance, ITask> uniqueTasks = preparationTaskHandlingStrategy.createSymbolMap(); 206 SymbolMap<ITaskInstance, ITask> uniqueTasks = preparationTaskHandlingStrategy 207 .createSymbolMap(); 210 208 211 209 TaskInstanceComparator comparator = preparationTaskHandlingStrategy … … 223 221 224 222 if (task == null) { 225 uniqueTasks.addSymbol(taskInstance, 223 uniqueTasks.addSymbol(taskInstance, taskInstance.getTask()); 224 appData.getUniqueTasks().add(taskInstance.getTask()); 225 appData.getNumber2Task().put( 226 taskInstance.getTask().getId(), 226 227 taskInstance.getTask()); 227 appData.getUniqueTasks().add(taskInstance.getTask());228 appData.getNumber2Task().put(taskInstance.getTask().getId(),taskInstance.getTask());229 228 } else { 230 229 taskBuilder.setTask(taskInstance, task); … … 323 322 324 323 IIteration iteration = taskFactory.createNewIteration(); 325 appData.getUniqueTasks().add( 324 appData.getUniqueTasks().add(iteration); 326 325 appData.getNumber2Task().put(iteration.getId(), iteration); 327 326 iterations.put(iteratedTask, iteration); … … 350 349 .createNewTaskInstance(iteration); 351 350 iterationInstances.get(iteration) 352 .add(iterationInstance);//TODO:: Don't create TaskInstances here, use a set of tasks instead 351 .add(iterationInstance);// TODO:: Don't create 352 // TaskInstances here, 353 // use a set of tasks 354 // instead 353 355 taskBuilder.addTaskInstance(session, index, 354 356 iterationInstance); … … 366 368 } 367 369 } 368 369 for (Map.Entry<IIteration, List<IIterationInstance>> entry : iterationInstances.entrySet()) 370 { 371 harmonizeIterationInstancesModel(entry.getKey(), entry.getValue()); 372 } 373 } 374 375 376 /** 377 * <p> 378 * TODO clarify why this is done 379 * </p> 380 */ 381 private void harmonizeIterationInstancesModel(IIteration iteration, 382 List<IIterationInstance> iterationInstances) 383 { 384 List<ITask> iteratedTaskVariants = new LinkedList<ITask>(); 385 TaskInstanceComparator comparator = preparationTaskHandlingStrategy.getTaskComparator(); 386 387 // merge the lexically different variants of iterated task to a unique list 388 for (IIterationInstance iterationInstance : iterationInstances) { 389 for (ITaskInstance executionVariant : iterationInstance) { 390 ITask candidate = executionVariant.getTask(); 391 392 boolean found = false; 393 for (ITask taskVariant : iteratedTaskVariants) { 394 if (comparator.areLexicallyEqual(taskVariant, candidate)) { 395 taskBuilder.setTask(executionVariant, taskVariant); 396 found = true; 397 break; 398 } 399 } 400 401 if (!found) { 402 iteratedTaskVariants.add(candidate); 403 } 404 } 405 } 406 407 // if there are more than one lexically different variant of iterated tasks, adapt the 408 // iteration model to be a selection of different variants. In this case also adapt 409 // the generated iteration instances to correctly contain selection instances. If there 410 // is only one variant of an iterated task, simply set this as the marked task of the 411 // iteration. In this case, the instances can be preserved as is 412 if (iteratedTaskVariants.size() > 1) { 413 ISelection selection = taskFactory.createNewSelection(); 414 415 for (ITask variant : iteratedTaskVariants) { 416 taskBuilder.addChild(selection, variant); 417 } 418 419 taskBuilder.setMarkedTask(iteration, selection); 420 421 for (IIterationInstance instance : iterationInstances) { 422 for (int i = 0; i < instance.size(); i++) { 423 ISelectionInstance selectionInstance = 424 taskFactory.createNewTaskInstance(selection); 425 taskBuilder.setChild(selectionInstance, instance.get(i)); 426 taskBuilder.setTaskInstance(instance, i, selectionInstance); 427 } 428 } 429 } 430 else { 431 taskBuilder.setMarkedTask(iteration, iteratedTaskVariants.get(0)); 432 } 433 } 434 435 436 ISequence matchAsSequence(RuleApplicationData appData, Match m) { 437 370 371 for (Map.Entry<IIteration, List<IIterationInstance>> entry : iterationInstances 372 .entrySet()) { 373 harmonizeIterationInstancesModel(entry.getKey(), entry.getValue()); 374 } 375 } 376 377 /** 378 * <p> 379 * TODO clarify why this is done 380 * </p> 381 */ 382 private void harmonizeIterationInstancesModel(IIteration iteration, 383 List<IIterationInstance> iterationInstances) { 384 List<ITask> iteratedTaskVariants = new LinkedList<ITask>(); 385 TaskInstanceComparator comparator = preparationTaskHandlingStrategy 386 .getTaskComparator(); 387 388 // merge the lexically different variants of iterated task to a unique 389 // list 390 for (IIterationInstance iterationInstance : iterationInstances) { 391 for (ITaskInstance executionVariant : iterationInstance) { 392 ITask candidate = executionVariant.getTask(); 393 394 boolean found = false; 395 for (ITask taskVariant : iteratedTaskVariants) { 396 if (comparator.areLexicallyEqual(taskVariant, candidate)) { 397 taskBuilder.setTask(executionVariant, taskVariant); 398 found = true; 399 break; 400 } 401 } 402 403 if (!found) { 404 iteratedTaskVariants.add(candidate); 405 } 406 } 407 } 408 409 // if there are more than one lexically different variant of iterated 410 // tasks, adapt the 411 // iteration model to be a selection of different variants. In this case 412 // also adapt 413 // the generated iteration instances to correctly contain selection 414 // instances. If there 415 // is only one variant of an iterated task, simply set this as the 416 // marked task of the 417 // iteration. In this case, the instances can be preserved as is 418 if (iteratedTaskVariants.size() > 1) { 419 ISelection selection = taskFactory.createNewSelection(); 420 421 for (ITask variant : iteratedTaskVariants) { 422 taskBuilder.addChild(selection, variant); 423 } 424 425 taskBuilder.setMarkedTask(iteration, selection); 426 427 for (IIterationInstance instance : iterationInstances) { 428 for (int i = 0; i < instance.size(); i++) { 429 ISelectionInstance selectionInstance = taskFactory 430 .createNewTaskInstance(selection); 431 taskBuilder.setChild(selectionInstance, instance.get(i)); 432 taskBuilder.setTaskInstance(instance, i, selectionInstance); 433 } 434 } 435 } else { 436 taskBuilder.setMarkedTask(iteration, iteratedTaskVariants.get(0)); 437 } 438 } 439 440 /** 441 * @param appData 442 * @param m 443 * @return 444 */ 445 public ISequence matchAsSequence(RuleApplicationData appData, Match m) { 446 447 System.out.println("DEBUGGING MODEL GENERATION"); 448 System.out.println(); 449 438 450 ISequence sequence = taskFactory.createNewSequence(); 439 451 appData.uniqueTasks.add(sequence); 440 452 appData.number2task.put(sequence.getId(), sequence); 441 442 453 443 454 int[] first = m.getFirstSequence().getSequence(); … … 450 461 // far, just to handle it 451 462 if (first[i] == -1 && second[i] == -1) { 452 // TODO: Do nothing?463 // Do nothing here. 453 464 } 454 465 // Both events are equal, we can simply add the task referring to … … 478 489 taskBuilder.addChild(sequence, optional); 479 490 } 480 // Both tasks are not equal, we need to insert a selection here 491 // Both tasks are not equal, we need to insert a selection here. 492 // Check if the next position is not a selection 493 else if (i < first.length - 1) { 494 495 if ((first[i] != second[i]) 496 && ((first[i + 1] == second[i + 1] 497 || first[i + 1] == -1 || second[i + 1] == -1))) { 498 499 ISelection selection = taskFactory.createNewSelection(); 500 appData.getUniqueTasks().add(selection); 501 appData.number2task.put(selection.getId(), selection); 502 taskBuilder.addChild(selection, appData.getNumber2Task() 503 .get(first[i])); 504 taskBuilder.addChild(selection, appData.getNumber2Task() 505 .get(second[i])); 506 taskBuilder.addChild(sequence, selection); 507 } else { 508 System.out.println("SELECTION OF SEQUENCES FOUND!"); 509 boolean selectionfound = true; 510 ISelection selection = taskFactory.createNewSelection(); 511 appData.getUniqueTasks().add(selection); 512 appData.number2task.put(selection.getId(), selection); 513 514 ISequence subsequence1 = taskFactory.createNewSequence(); 515 appData.uniqueTasks.add(subsequence1); 516 appData.number2task.put(subsequence1.getId(), subsequence1); 517 518 ISequence subsequence2 = taskFactory.createNewSequence(); 519 appData.uniqueTasks.add(subsequence2); 520 appData.number2task.put(subsequence2.getId(), subsequence2); 521 522 taskBuilder.addChild(selection, subsequence1); 523 taskBuilder.addChild(selection, subsequence2); 524 taskBuilder.addChild(sequence,selection); 525 while (i < first.length - 1 && selectionfound) { 526 selectionfound = false; 527 taskBuilder.addChild(subsequence1, appData 528 .getNumber2Task().get(first[i])); 529 taskBuilder.addChild(subsequence2, appData 530 .getNumber2Task().get(second[i])); 531 if (first[i + 1] != second[i + 1] && first[i + 1] != -1 532 && second[i + 1] != -1) { 533 selectionfound = true; 534 } 535 i++; 536 } 537 if(i==first.length-1 && selectionfound) { 538 taskBuilder.addChild(subsequence1, appData 539 .getNumber2Task().get(first[i])); 540 taskBuilder.addChild(subsequence2, appData 541 .getNumber2Task().get(second[i])); 542 } 543 } 544 } 545 481 546 else { 482 ISelection selection = taskFactory.createNewSelection(); 483 appData.getUniqueTasks().add(selection); 484 appData.number2task.put(selection.getId(), selection); 485 taskBuilder.addChild(selection, 486 appData.getNumber2Task().get(first[i])); 487 taskBuilder.addChild(selection, 488 appData.getNumber2Task().get(second[i])); 489 taskBuilder.addChild(sequence, selection); 490 } 491 } 492 493 // TODO: Debug output 494 /* 495 * for (int i =0;i<sequence.getChildren().size();i++) { 496 * System.out.println(sequence.getChildren().get(i)); 497 * 498 * if(sequence.getChildren().get(i).getType() == "selection") { for(int 499 * j=0; j< ((ISelection) 500 * sequence.getChildren().get(i)).getChildren().size();j++) { 501 * System.out.println("\t" +((ISelection) 502 * sequence.getChildren().get(i)).getChildren().get(j)); } } } 503 */ 547 if ((first[i] != second[i])) { 548 549 ISelection selection = taskFactory.createNewSelection(); 550 appData.getUniqueTasks().add(selection); 551 appData.number2task.put(selection.getId(), selection); 552 taskBuilder.addChild(selection, appData.getNumber2Task() 553 .get(first[i])); 554 taskBuilder.addChild(selection, appData.getNumber2Task() 555 .get(second[i])); 556 taskBuilder.addChild(sequence, selection); 557 } 558 } 559 560 } 504 561 return sequence; 505 562 } 506 507 563 508 564 /** … … 546 602 } 547 603 } 548 604 549 605 Console.traceln(Level.FINEST, 550 606 "retrieving significant sequence pieces: 100%"); … … 598 654 // well 599 655 if (matchseqs.get(i).occurenceCount() > 2) { 600 656 601 657 appData.detectedAndReplacedTasks = true; 602 658 ISequence task = matchAsSequence(appData, matchseqs.get(i)); … … 604 660 .get(i).getOccurences().iterator(); it.hasNext();) { 605 661 MatchOccurence oc = it.next(); 606 607 if(iteration==-1) { 608 System.out.println("Trying to replace sequence: "); 609 matchseqs.get(i).getFirstSequence().printSequence(); 610 matchseqs.get(i).getSecondSequence().printSequence(); 611 System.out.println(" in session number: " + 612 (oc.getSequenceId() + 1) + " at position " + 613 (oc.getStartindex()) + "-" + oc.getEndindex()); 614 System.out.println(); 662 663 if (iteration > 0) { 615 664 616 617 System.out.println("Printing session: "); 618 for (int j = 0; j < 619 appData.getSessions().get(oc.getSequenceId()).size(); 620 j++) { 621 System.out.println(j + ": " 622 + appData.getSessions().get(oc.getSequenceId()).get(j)); 623 } 665 System.out.println("Trying to replace sequence: "); 666 matchseqs.get(i).getFirstSequence().printSequence(); 667 matchseqs.get(i).getSecondSequence().printSequence(); 668 System.out.println(" in session number: " 669 + (oc.getSequenceId() + 1) + " at position " 670 + (oc.getStartindex()) + "-" + oc.getEndindex()); 671 System.out.println(); 672 673 System.out.println("Printing session: "); 674 for (int j = 0; j < appData.getSessions() 675 .get(oc.getSequenceId()).size(); j++) { 676 System.out.println(j 677 + ": " 678 + appData.getSessions().get(oc.getSequenceId()) 679 .get(j)); 624 680 } 625 681 } 626 682 // Check if nothing has been replaced in the sequence we 627 683 // want to replace … … 687 743 } 688 744 689 690 691 745 /** 692 746 * … … 696 750 private HashMap<Integer, ITask> number2task; 697 751 698 // TODO: We Actually just need number2task here752 // TODO: We Actually just need number2task here 699 753 private HashSet<ITask> uniqueTasks; 700 754
Note: See TracChangeset
for help on using the changeset viewer.