Legend:
- Unmodified
- Added
- Removed
-
branches/autoquest-core-tasktrees-alignment-test/src/test/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NumberSequenceTest.java
r1662 r1665 18 18 int[] seq3 = new int[]{0,0,5,6,0,6,9,10,0,12,13,0,15,16,0,13,0,15,21,13,0,15,21,0,0,0,6,0,9,32,0,5,10,0,6,0,9,32,0,5,43,0,6,0,9,5,6,0,9,43,0,6,0,9,32,0,5,6,6,9,43,0,0,0,0}; 19 19 20 20 int[] seq4 = new int[]{32,32,5,6,9,10,0}; 21 21 int[] pat1 = new int[]{2,3,4}; 22 22 int[] pat2 = new int[]{2,3,4}; … … 44 44 //int[] pat16 = new int[]{6,-1, 9,71,32, 5,10,0}; 45 45 46 int[] pat17 = new int[]{32,0,5,10}; 47 int[] pat18 = new int[]{271,-1,32,247}; 48 49 46 50 NumberSequence ns = new NumberSequence(10); 47 51 ns.setSequence(seq); … … 50 54 ns2.setSequence(seq3); 51 55 56 NumberSequence ns3 = new NumberSequence(7); 57 ns3.setSequence(seq4); 58 59 52 60 NumberSequence firstpattern = new NumberSequence(3); 53 61 NumberSequence secondpattern = new NumberSequence(3); … … 59 67 NumberSequence sixthpattern = new NumberSequence(pat14.length); 60 68 69 NumberSequence seventhpattern = new NumberSequence(pat17.length); 70 NumberSequence eigthpattern = new NumberSequence(pat17.length); 71 72 61 73 firstpattern.setSequence(pat1); 62 74 secondpattern.setSequence(pat2); … … 68 80 sixthpattern.setSequence(pat14); 69 81 82 seventhpattern.setSequence(pat17); 83 eigthpattern.setSequence(pat18); 70 84 71 85 Match pattern = new Match(); … … 80 94 pattern3.setFirstSequence(fifthpattern); 81 95 pattern3.setSecondSequence(sixthpattern); 82 96 97 Match pattern4 = new Match(); 98 pattern4.setFirstSequence(seventhpattern); 99 pattern4.setSecondSequence(eigthpattern); 83 100 84 101 assertEquals(Integer.valueOf(2),ns.containsPattern(pattern).get(0)); … … 129 146 130 147 148 assertEquals(0,ns3.containsPattern(pattern4).size()); 131 149 132 150 } -
branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NumberSequence.java
r1662 r1665 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 ) {47 private boolean matches(int i, int[] p1, int[] p2 ,int ip1,int ip2,boolean jumped1,boolean jumped2) { 48 48 49 49 if(p1.length==ip1) { … … 56 56 return false; 57 57 } 58 if((p1[ip1]==sequence[i]||p2[ip2]==sequence[i]) && jumped1) { 59 return matches(i+1,p1,p2,ip1+1,ip2+2,false,false); 60 } 61 if((p1[ip1]==sequence[i]||p2[ip2]==sequence[i]) && jumped2) { 62 return matches(i+1,p1,p2,ip1+2,ip2+1,false,false); 63 } 58 64 if(p1[ip1]==sequence[i]||p2[ip2]==sequence[i]) { 59 return matches(i+1,p1,p2,ip1+1,ip2+1 );65 return matches(i+1,p1,p2,ip1+1,ip2+1,false,false); 60 66 } 61 67 if(p1[ip1]==-1) { 62 return matches(i,p1,p2,ip1+1,ip2 );68 return matches(i,p1,p2,ip1+1,ip2,true,false); 63 69 } 64 70 if(p2[ip2]==-1) { 65 return matches(i,p1,p2,ip1,ip2+1 );71 return matches(i,p1,p2,ip1,ip2+1,false,true); 66 72 } 73 67 74 return false; 68 75 } … … 76 83 77 84 while (i < sequence.length ) { 78 if(matches(i,pat1,pat2,0,0 )) {85 if(matches(i,pat1,pat2,0,0,false,false)) { 79 86 result.add(i); 80 87 }
Note: See TracChangeset
for help on using the changeset viewer.