Ignore:
Timestamp:
08/24/14 21:12:44 (10 years ago)
Author:
rkrimmel
Message:

Creating more complex models...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/autoquest-core-tasktrees-alignment/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/algorithms/NumberSequence.java

    r1665 r1693  
    4545 
    4646        //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) { 
    4857                 
    4958                if(p1.length==ip1) { 
     
    5665                        return false; 
    5766                } 
    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                        } 
    6085                } 
    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); 
    6389                } 
    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); 
    6695                } 
    6796                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); 
    6998                } 
    7099                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); 
    72101                } 
    73102         
     
    83112 
    84113                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)) { 
    86115                                result.add(i); 
    87116                        } 
Note: See TracChangeset for help on using the changeset viewer.