Ignore:
Timestamp:
07/23/14 18:18:11 (10 years ago)
Author:
rkrimmel
Message:

More intelligent match finding and creation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignment.java

    r1619 r1620  
    2626 
    2727import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.AlignmentAlgorithmFactory; 
     28import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.Match; 
    2829import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.NumberSequence; 
    2930import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.PairwiseAlignmentGenerator; 
     
    155156                Console.traceln(Level.INFO,"generating substitution matrix"); 
    156157                ObjectDistanceSubstitionMatrix submat = new ObjectDistanceSubstitionMatrix( 
    157                                 uniqueTasks, 5); 
     158                                uniqueTasks, 6,-3); 
    158159                submat.generate(); 
    159160 
    160161                Console.traceln(Level.INFO,"generating pairwise alignments"); 
    161                 ArrayList<ArrayList<NumberSequence>> matchseqs = new ArrayList<ArrayList<NumberSequence>>(); 
    162                 PairwiseAlignmentStorage alignments = PairwiseAlignmentGenerator.generate(numberseqs,submat); 
     162                ArrayList<Match> matchseqs = new ArrayList<Match>(); 
     163                PairwiseAlignmentStorage alignments = PairwiseAlignmentGenerator.generate(numberseqs,submat,9); 
    163164                 
    164165                Console.traceln(Level.INFO,"retrieving significant sequence pieces"); 
     
    167168                        for(int j=0; j< numberseqs.size();j++) { 
    168169                                if(i != j) { 
    169                                         ArrayList<ArrayList<NumberSequence>> tmp = alignments.get(i, j).getMatches(); 
    170                                         matchseqs.addAll(tmp); 
     170                                        matchseqs.addAll(alignments.get(i, j).getMatches()); 
    171171                                }    
    172172                        } 
     
    178178                //search this match in every other sequence 
    179179                for(int i=0; i < matchseqs.size();i++) { 
    180                         int occurencecount = 0; 
     180                        int sequencecount = 0; 
     181                        int totalcount = 0; 
     182                        Match pattern = matchseqs.get(i); 
     183                         
     184                 
     185                         
     186                        //Skip sequences with more 0 events (scrolls) than other events. Both of the pattern sequences are equally long, so the added 0 counts  
     187                        //just need to be smaller than the length of one sequence  
     188                        if(pattern.getFirstSequence().eventCount(0) + pattern.getSecondSequence().eventCount(0) +1 > pattern.getFirstSequence().size()) 
     189                                continue; 
    181190                        Console.traceln(Level.FINEST, "searching for patterns occuring most: " + Math.round((float)i/(float)matchseqs.size()*100) + "%"); 
    182                         for(int j=0; j < matchseqs.size();j++) { 
    183                                 if(i>j) { 
    184                                         if(matchseqs.get(j).get(0).containsPattern(matchseqs.get(i)) > 0 || matchseqs.get(j).get(1).containsPattern(matchseqs.get(i)) > 0) { 
    185                                                 occurencecount++; 
     191                        for(int j=0; j < numberseqs.size();j++) { 
     192                                        int tmpcount = numberseqs.get(j).containsPattern(pattern); 
     193                                        if(tmpcount > 0) { 
     194                                                sequencecount++; 
     195                                                totalcount+=tmpcount; 
    186196                                        } 
    187                                 } 
    188                         } 
    189                         if(occurencecount > 1) { 
    190                                 System.out.println("Found pattern \n ");  
    191                                 matchseqs.get(i).get(0).printSequence();  
    192                                 matchseqs.get(i).get(1).printSequence();  
    193                                 System.out.println(occurencecount + " times"); 
     197                        } 
     198                         
     199                        if(totalcount > 1) { 
     200                                matchseqs.get(i).getFirstSequence().printSequence();  
     201                                matchseqs.get(i).getFirstSequence().printSequence(); 
     202                                System.out.println("Found pattern in " + sequencecount +"/" + numberseqs.size() + " sequences, total of " + totalcount + " occurences"); 
    194203                                System.out.println(); 
    195204                        } 
    196205                } 
    197                  
    198                  
    199                  
    200206                alignments = null; 
    201207                 
     
    290296                                } 
    291297                        } 
     298                        templist.setId(numberseqs.size()); 
    292299                        numberseqs.add(templist); 
    293300                        comparator.clearBuffers(); 
Note: See TracChangeset for help on using the changeset viewer.