Ignore:
Timestamp:
08/24/16 10:17:41 (8 years ago)
Author:
pharms
Message:
  • added possibility to select the minimal amount of action instances a detected sequence must cover
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TemporalRelationshipRuleManager.java

    r1889 r2132  
    2525import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 
    2626import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 
    27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance; 
    2827import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 
    2928import de.ugoe.cs.util.console.Console; 
     
    102101    /** 
    103102     * <p> 
    104      * the temporal relationship rules known to the manager that are executed on whole sessions. 
    105      * The rules are applied in the order they occur in this list. 
    106      * </p> 
    107      */ 
    108     private ISessionScopeRule[] sessionScopeRules; 
    109  
    110     /** 
    111      * <p> 
    112      * the temporal relationship rules known to the manager that are executed on whole sub trees. 
    113      * The rules are applied in the order they occur in this list. 
    114      * </p> 
    115      */ 
    116     private ITaskInstanceScopeRule[] taskScopeRules; 
    117  
    118     /** 
    119      * <p> 
    120103     * initialize the manager 
    121104     * </p> 
     
    144127        frameFilter.add(IDialog.class); 
    145128        //frameFilter.add(ICanvas.class); 
    146  
    147         sessionScopeRules = new ISessionScopeRule[] { 
    148             new SequenceForTaskDetectionRule 
    149                 (TaskEquality.SEMANTICALLY_EQUAL, taskFactory, taskBuilder), 
    150             new CondenseSimilarTasksRule 
    151                 (TaskEquality.SEMANTICALLY_EQUAL, taskFactory, taskBuilder), 
    152             /*new DefaultTaskSequenceDetectionRule 
    153                 (NodeEquality.SYNTACTICALLY_EQUAL, taskFactory, taskTreeBuilder), 
    154             new DefaultTaskSequenceDetectionRule 
    155                 (NodeEquality.LEXICALLY_EQUAL, taskFactory, taskTreeBuilder),*/ 
    156             /*new TreeScopeWrapperRule 
    157                 (new DefaultIterationDetectionRule 
    158                     (NodeEquality.LEXICALLY_EQUAL, taskFactory, taskTreeBuilder)), 
    159             new TreeScopeWrapperRule 
    160                 (new DefaultIterationDetectionRule 
    161                     (NodeEquality.SYNTACTICALLY_EQUAL, taskFactory, taskTreeBuilder)), 
    162             new TreeScopeWrapperRule 
    163                 (new DefaultIterationDetectionRule 
    164                     (NodeEquality.SEMANTICALLY_EQUAL, taskFactory, taskTreeBuilder))*/ 
    165         }; 
    166          
    167         //treeScopeRules.add(new DefaultGuiElementSequenceDetectionRule(frameFilter)); 
    168  
    169         taskScopeRules = new ITaskInstanceScopeRule[] { 
    170             //new SequenceOnGuiElementDetectionRule(taskFactory, taskTreeBuilder), 
    171             //new EventSequenceOnSameTargetDetectionRule(taskFactory, taskTreeBuilder), 
    172             //new TrackBarSelectionDetectionRule(taskFactory, taskBuilder), 
    173             //new DefaultGuiEventSequenceDetectionRule(taskFactory, taskTreeBuilder), 
    174         }; 
    175  
    176     } 
    177  
    178     /** 
    179      * <p> 
    180      * applies the known rules to the provided sessions. For the creation of further tasks, 
    181      * the provided builder and task factory are utilized. The method expects, that no more data 
    182      * is available and, therefore, finalizes the rule application. 
    183      * </p> 
    184      *  
    185      * @param sessions  the sessions to be processed 
    186      */ 
    187     public void applyRules(List<IUserSession> sessions) { 
    188         applyRules(sessionScopeRules, sessions, ""); 
    189129    } 
    190130 
     
    197137     * @param sessions  the sessions to be processed 
    198138     */ 
    199     public void applyTaskDetectionRule(List<IUserSession> sessions) { 
     139    public void applyTaskDetectionRule(List<IUserSession> sessions, 
     140                                       TaskEquality       minimalTaskEquality, 
     141                                       int                minimumSequenceCoverage) 
     142    { 
    200143        ISessionScopeRule[] rules = new ISessionScopeRule[] { 
    201             new SequenceForTaskDetectionRule 
    202                 (TaskEquality.SEMANTICALLY_EQUAL, taskFactory, taskBuilder) 
     144            new SequenceForTaskDetectionRule(minimalTaskEquality, taskFactory, taskBuilder, 
     145                                             minimumSequenceCoverage) 
    203146        }; 
    204147         
     
    261204                     
    262205                    //dumpTask(parent, ""); 
    263  
    264                     for (ITaskInstance newParent : result.getNewlyCreatedTaskInstances()) { 
    265                         noOfRuleApplications += 
    266                             applyRules(taskScopeRules, newParent, logIndent + "  "); 
    267                     } 
    268206                } 
    269207            } 
     
    271209                   (result.getRuleApplicationStatus() == RuleApplicationStatus.FINISHED)); 
    272210 
    273         } 
    274  
    275         if (noOfRuleApplications <= 0) { 
    276             Console.traceln(Level.FINE, logIndent + "no rules applied --> no temporal " + 
    277                             "relationship generated"); 
    278         } 
    279  
    280         return noOfRuleApplications; 
    281     } 
    282  
    283     /** 
    284      * <p> 
    285      * applies the known rules to the provided parent task. For the creation of further tasks, 
    286      * the provided builder and task factory are utilized. If the finalize parameter is true, the 
    287      * rule application is finalized as far as possible without waiting for further data. If it is 
    288      * false, the rule application is broken up at the first rule returning, that its application 
    289      * would be feasible. The method calls itself for each parent task created through the rule 
    290      * application. In this case, the finalize parameter is always true. 
    291      * </p> 
    292      *  
    293      * @param parent       the parent task to apply the rules on 
    294      * @param finalize     used to indicate, if the rule application shall break up if a rule would 
    295      *                     be feasible if further data was available, or not. 
    296      * @param logIndent    simply used for logging purposes to indent the log messages depending 
    297      *                     on the recursion depth of calling this method. 
    298      */ 
    299     private int applyRules(ITaskInstanceScopeRule[] rules, 
    300                            ITaskInstance                taskInstance, 
    301                            String                       logIndent) 
    302     { 
    303         Console.traceln(Level.FINER, logIndent + "applying rules on " + taskInstance); 
    304  
    305         int noOfRuleApplications = 0; 
    306  
    307         for (ITaskInstanceScopeRule rule : rules) { 
    308             RuleApplicationResult result; 
    309             do { 
    310                 Console.traceln 
    311                     (Level.FINER, logIndent + "trying rule " + rule + " on " + taskInstance); 
    312                 result = rule.apply(taskInstance); 
    313  
    314                 if ((result != null) && 
    315                     (result.getRuleApplicationStatus() == RuleApplicationStatus.FINISHED)) 
    316                 { 
    317                     Console.traceln 
    318                         (Level.FINE, logIndent + "applied rule " + rule + " on " + taskInstance); 
    319                     noOfRuleApplications++; 
    320                      
    321                     //dumpTask(parent, ""); 
    322  
    323                     for (ITaskInstance newParent : result.getNewlyCreatedTaskInstances()) { 
    324                         noOfRuleApplications += 
    325                             applyRules(taskScopeRules, newParent, logIndent + "  "); 
    326                     } 
    327                 } 
    328             } 
    329             while ((result != null) && 
    330                    (result.getRuleApplicationStatus() == RuleApplicationStatus.FINISHED)); 
    331211        } 
    332212 
Note: See TracChangeset for help on using the changeset viewer.