Changeset 1649
- Timestamp:
- 08/03/14 22:53:27 (10 years ago)
- Location:
- branches
- Files:
-
- 1 added
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/autoquest-core-tasktrees-alignment-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NumberSequenceTest.java
r1648 r1649 21 21 22 22 int[] pat5 = new int[]{-1,-1,-1}; 23 23 24 int[] pat6 = new int[]{10,11,12}; 25 26 int[] pat7 = new int[]{8,9,10}; 27 int[] pat8 = new int[]{7,6,5}; 28 29 int[] pat9 = new int[]{0}; 30 int[] pat10 = new int[]{1}; 24 31 25 32 … … 34 41 Match pattern = new Match(); 35 42 pattern.setFirstSequence(firstpattern); 36 pattern.setSecondSequence(secondpattern); 37 43 pattern.setSecondSequence(secondpattern); 38 44 assertEquals(Integer.valueOf(2),ns.containsPattern(pattern).get(0)); 45 assertEquals(1,ns.containsPattern(pattern).size()); 39 46 40 47 firstpattern.setSequence(pat3); … … 43 50 assertEquals(Integer.valueOf(1),ns.containsPattern(pattern).get(0)); 44 51 assertEquals(Integer.valueOf(5),ns.containsPattern(pattern).get(1)); 52 assertEquals(2,ns.containsPattern(pattern).size()); 45 53 46 54 firstpattern.setSequence(pat5); 47 55 secondpattern.setSequence(pat5); 48 49 56 assertEquals(0,ns.containsPattern(pattern).size()); 50 57 51 58 firstpattern.setSequence(pat6); 52 59 secondpattern.setSequence(pat6); 60 assertEquals(0,ns.containsPattern(pattern).size()); 53 61 62 firstpattern.setSequence(pat7); 63 secondpattern.setSequence(pat8); 54 64 assertEquals(0,ns.containsPattern(pattern).size()); 65 66 firstpattern.setSequence(pat9); 67 secondpattern.setSequence(pat10); 68 assertEquals(Integer.valueOf(0),ns.containsPattern(pattern).get(0)); 69 assertEquals(Integer.valueOf(1),ns.containsPattern(pattern).get(1)); 70 assertEquals(2,ns.containsPattern(pattern).size()); 71 55 72 } 56 73 -
branches/autoquest-core-tasktrees-alignment-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWatermanRepeatedTest.java
r1648 r1649 5 5 import org.junit.Test; 6 6 7 import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.DummySubstitutionMatrix; 8 7 9 public class SmithWatermanRepeatedTest { 8 10 9 11 @Test 10 12 public void testGetMaxScore() { 11 fail("Not yet implemented"); 13 int[] seq1 = new int[]{0,1,2,3,4,5,6,7,8,9}; 14 int[] seq2 = new int[]{0,1,2,3,4,5,6,7,8,9}; 15 16 NumberSequence ns1 = new NumberSequence(10); 17 NumberSequence ns2 = new NumberSequence(10); 18 19 ns1.setSequence(seq1); 20 ns2.setSequence(seq2); 21 22 DummySubstitutionMatrix submat = new DummySubstitutionMatrix(); 23 24 AlignmentAlgorithm testalignment1 = AlignmentAlgorithmFactory 25 .create(); 26 testalignment1.align(ns1, ns2,submat,5); 27 28 assertTrue(testalignment1.getMaxScore()==10); 12 29 } 13 30 14 31 @Test 15 32 public void testGetAlignmentScore() { 16 fail("Not yet implemented"); 33 int[] seq1 = new int[]{0,1,2,3,4,5,6,7,8,9}; 34 int[] seq2 = new int[]{0,1,2,3,4,5,6,7,8,9}; 35 36 NumberSequence ns1 = new NumberSequence(10); 37 NumberSequence ns2 = new NumberSequence(10); 38 39 ns1.setSequence(seq1); 40 ns2.setSequence(seq2); 41 42 DummySubstitutionMatrix submat = new DummySubstitutionMatrix(); 43 44 AlignmentAlgorithm testalignment1 = AlignmentAlgorithmFactory 45 .create(); 46 testalignment1.align(ns1, ns2,submat,5); 47 assertTrue(testalignment1.getAlignmentScore()==5); 17 48 } 18 49 19 50 @Test 20 51 public void testGetMatches() { 21 fail("Not yet implemented"); 52 int[] seq1 = new int[]{0,1,2,3,4,5,6,7,8,9}; 53 int[] seq2 = new int[]{3,4,5,6,7}; 54 55 NumberSequence ns1 = new NumberSequence(10); 56 NumberSequence ns2 = new NumberSequence(10); 57 58 ns1.setSequence(seq1); 59 ns2.setSequence(seq2); 60 61 DummySubstitutionMatrix submat = new DummySubstitutionMatrix(); 62 63 AlignmentAlgorithm testalignment1 = AlignmentAlgorithmFactory 64 .create(); 65 testalignment1.align(ns1, ns2,submat,4); 66 testalignment1.printDPMatrix(); 67 testalignment1.printAlignment(); 68 69 //testalignment1.getMatches().get(0).getFirstSequence().printSequence(); 70 //testalignment1.getMatches().get(0).getSecondSequence().printSequence(); 71 22 72 } 23 73 24 @Test25 public void testGetAlignment() {26 fail("Not yet implemented");27 }28 74 75 //TODO: Need a better substitution matrix to do proper testing 29 76 @Test 30 77 public void testAlign() { 31 fail("Not yet implemented"); 32 } 78 int[] seq1 = new int[]{0,1,2, 3, 4, 5,6,7,8,9}; 79 int[] seq2 = new int[]{0,1,2,10,11,12,6,7,8,9}; 80 81 82 NumberSequence ns1 = new NumberSequence(10); 83 NumberSequence ns2 = new NumberSequence(10); 84 85 ns1.setSequence(seq1); 86 ns2.setSequence(seq2); 87 88 DummySubstitutionMatrix submat = new DummySubstitutionMatrix(); 89 90 AlignmentAlgorithm testalignment1 = AlignmentAlgorithmFactory 91 .create(); 92 testalignment1.align(ns1, ns2,submat,3); 93 //assertTrue(testalignment1.getAlignmentScore()==7); 94 95 } 33 96 34 97 } -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/AlignmentAlgorithm.java
r1620 r1649 19 19 20 20 public abstract ArrayList<Match> getMatches(); 21 22 public double getMaxScore(); 21 23 22 24 void align(NumberSequence input1, NumberSequence input2, -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/SmithWatermanRepeated.java
r1620 r1649 102 102 //position of the maximal score of the previous row 103 103 104 for(int j = 2; j < length2;j++) {104 for(int j = 2; j <= length2;j++) { 105 105 if(matrix[i-1][j].getScore() > tempMax) { 106 106 tempMax = matrix[i-1][j].getScore(); … … 122 122 123 123 //The last additional score is not related to a character in the input sequence, it's the total score. Therefore we don't need to save something for it 124 if(i<length1+1)125 {124 //and can end here 125 if(i<length1+1) { 126 126 matrix[i][0].setXvalue(input1[i-1]); 127 127 matrix[i][0].setYvalue(Constants.UNMATCHED_SYMBOL); 128 128 } 129 else { 130 //End after we calculated final score 129 else { 131 130 return; 132 131 } 133 134 135 for (int j = 1; j < length2; j++) { 132 133 134 135 for (int j = 1; j <= length2; j++) { 136 136 double diagScore = matrix[i - 1][j - 1].getScore() + similarity(i, j); 137 137 double upScore = matrix[i][j - 1].getScore() + submat.getGapPenalty(); … … 181 181 // skip the first row and column 182 182 for (int i = 1; i <= length1; i++) { 183 for (int j = 1; j < length2; j++) {183 for (int j = 1; j <= length2; j++) { 184 184 if (matrix[i][j].getScore() > maxScore) { 185 185 maxScore = matrix[i][j].getScore(); … … 373 373 374 374 for (int i = 0; i <= length1+1; i++) { 375 for(int j = 0; j< length2; j++) {375 for(int j = 0; j<= length2; j++) { 376 376 matrix[i][j] = new MatrixEntry(); 377 377 } -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignment.java
r1645 r1649 166 166 .generate(appData.getNumberSequences(), submat, 9); 167 167 168 169 168 170 // Retrieve all matches reached a specific threshold 169 171 Console.traceln(Level.INFO, "retrieving significant sequence pieces"); … … 203 205 for (Iterator<Integer> jt = startpositions.iterator(); jt 204 206 .hasNext();) { 207 int start = jt.next(); 208 System.out.println("Found match "); 209 pattern.getFirstSequence().printSequence(); 210 pattern.getSecondSequence().printSequence(); 211 System.out.println("in sequence " + (j+1) + " at position " + start); 205 212 pattern.addOccurence( 206 new MatchOccurence( jt.next(), j));213 new MatchOccurence(start, j)); 207 214 } 208 215 … … 366 373 } 367 374 appData.getNumber2Task().put(templist.getSequence()[i], taskInstance.getTask()); 375 376 //System.out.println("TaskID: " + taskInstance.getTask().getId()+ " Numbersequence: " + templist.getSequence()[i]); 368 377 } 369 378 //Each NumberSequence is identified by its id, beginning to count at zero 370 templist.setId( appData.getNumberSequences().size());379 templist.setId(sessionNo-1); 371 380 appData.getNumberSequences().add(templist); 372 381 comparator.clearBuffers(); … … 550 559 } 551 560 } 561 for (int i =0;i<sequence.getChildren().size();i++) { 562 System.out.println(sequence.getChildren().get(i)); 563 564 if(sequence.getChildren().get(i).getType() == "selection") { 565 for(int j=0; j< ((ISelection) sequence.getChildren().get(i)).getChildren().size();j++) { 566 System.out.println("\t" +((ISelection) sequence.getChildren().get(i)).getChildren().get(j)); 567 } 568 } 569 } 552 570 return sequence; 553 571 }
Note: See TracChangeset
for help on using the changeset viewer.