Changeset 2132
- Timestamp:
- 08/24/16 10:17:41 (8 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/manager/TaskTreeManager.java
r1889 r2132 16 16 17 17 import java.util.Collection; 18 import java.util.HashMap; 18 19 import java.util.LinkedList; 19 20 import java.util.List; 21 import java.util.Map; 20 22 import java.util.logging.Level; 21 23 22 24 import de.ugoe.cs.autoquest.eventcore.Event; 25 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 23 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 24 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; … … 72 75 /** 73 76 * <p> 77 * The default task equality considered when comparing task instances initially 78 * </p> 79 */ 80 private TaskEquality minimalTaskEquality = TaskEquality.SEMANTICALLY_EQUAL; 81 82 /** 83 * <p> 84 * If this flag is set, then the task tree manager will not create new event tasks for any 85 * events. Instead, it will check using the hashcode and equal methods of the provided events 86 * if a certain event has already occurred, and if so, the corresponding event task will be 87 * reused. 88 * </p> 89 */ 90 private boolean useEventEqualityForTaskComparison; 91 92 /** 93 * <p> 94 * the minimum number of event task instances a sequence must cover to still detect it as a 95 * representative task 96 * </p> 97 */ 98 private int minimumSequenceCoverage;; 99 100 /** 101 * <p> 102 * If the flag {@link #useEventEqualityForTaskComparison} is set, then here the task tree 103 * manager stores the already created event tasks. 104 * </p> 105 */ 106 private Map<Event, IEventTask> eventTasks = new HashMap<>(); 107 108 /** 109 * <p> 74 110 * initializes the task tree manager 75 111 * </p> 76 112 */ 77 113 public TaskTreeManager() { 78 sessions = new LinkedList<IUserSession>();114 this.sessions = new LinkedList<IUserSession>(); 79 115 } 80 116 … … 96 132 * single events 97 133 */ 98 public synchronized ITaskModel createTaskModel(Collection<List<Event>> newSessions) { 134 public synchronized ITaskModel createTaskModel(Collection<List<Event>> newSessions, 135 boolean useEventEqualityForTaskComparison, 136 int minimumSequenceCoverage) 137 { 99 138 if ((currentSession != null) || (sessions.size() > 0)) { 100 139 throw new IllegalStateException("do not mix calls to this method with calls to the " + … … 102 141 "variant instead."); 103 142 } 143 144 this.useEventEqualityForTaskComparison = useEventEqualityForTaskComparison; 145 146 if (useEventEqualityForTaskComparison) { 147 // if we do this, we also need to consider identity of event tasks afterwards 148 minimalTaskEquality = TaskEquality.IDENTICAL; 149 } 150 151 this.minimumSequenceCoverage = minimumSequenceCoverage; 104 152 105 153 for (List<Event> newSession : newSessions) { … … 117 165 /** 118 166 * <p> 167 * call {@link #createTaskModel(Collection, boolean, int)} with false for use event equality 168 * for comparison and 0 for the minimum number of covered events per sequence 169 * </p> 170 * 171 * @param newSessions the user sessions of which the task model shall be created 172 * 173 * @return the task model created from the user sessions 174 * 175 * @throws IllegalStateException if the task manager is already used by providing it with 176 * single events 177 */ 178 public synchronized ITaskModel createTaskModel(Collection<List<Event>> newSessions) { 179 return createTaskModel(newSessions, false, 0); 180 } 181 182 /** 183 * <p> 119 184 * handles a single event that occurred in a user session. 120 185 * </p> … … 124 189 public void handleNewEvent(Event event) { 125 190 assertSessionSequence(); 126 String description = event.getType().getName() + " \u21D2 " + event.getTarget(); 127 IEventTask eventTask = taskFactory.createNewEventTask(description); 128 taskBuilder.addExecutedTask 129 (currentSession, taskFactory.createNewTaskInstance(eventTask, event)); 191 192 if (!useEventEqualityForTaskComparison) { 193 String description = event.getType().getName() + " \u21D2 " + event.getTarget(); 194 IEventTask eventTask = taskFactory.createNewEventTask(description); 195 taskBuilder.addExecutedTask 196 (currentSession, taskFactory.createNewTaskInstance(eventTask, event)); 197 } 198 else { 199 IEventTask eventTask = eventTasks.get(event); 200 if (eventTask == null) { 201 String description = event.getType().getName() + " \u21D2 " + event.getTarget(); 202 eventTask = taskFactory.createNewEventTask(description); 203 eventTasks.put(event, eventTask); 204 } 205 206 taskBuilder.addExecutedTask 207 (currentSession, taskFactory.createNewTaskInstance(eventTask, event)); 208 } 130 209 } 131 210 … … 157 236 (Level.INFO, "applying temporal relationship generation rules for detecting tasks"); 158 237 159 ComponentManager.getTemporalRelationshipRuleManager().applyTaskDetectionRule(sessions); 238 ComponentManager.getTemporalRelationshipRuleManager().applyTaskDetectionRule 239 (sessions, minimalTaskEquality, minimumSequenceCoverage); 160 240 161 241 return taskFactory.createTaskModel(sessions); -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/CondenseSimilarTasksRule.java
r1982 r2132 444 444 445 445 new SequenceForTaskDetectionRule 446 (TaskEquality.IDENTICAL, taskFactory, taskBuilder ).apply(flattenedSessionList);446 (TaskEquality.IDENTICAL, taskFactory, taskBuilder, 0).apply(flattenedSessionList); 447 447 448 448 Map<ITaskInstance, ITaskInstance> replacements = new HashMap<ITaskInstance, ITaskInstance>(); -
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TemporalRelationshipRuleManager.java
r1889 r2132 25 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskBuilder; 26 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskFactory; 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskInstance;28 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.IUserSession; 29 28 import de.ugoe.cs.util.console.Console; … … 102 101 /** 103 102 * <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>120 103 * initialize the manager 121 104 * </p> … … 144 127 frameFilter.add(IDialog.class); 145 128 //frameFilter.add(ICanvas.class); 146 147 sessionScopeRules = new ISessionScopeRule[] {148 new SequenceForTaskDetectionRule149 (TaskEquality.SEMANTICALLY_EQUAL, taskFactory, taskBuilder),150 new CondenseSimilarTasksRule151 (TaskEquality.SEMANTICALLY_EQUAL, taskFactory, taskBuilder),152 /*new DefaultTaskSequenceDetectionRule153 (NodeEquality.SYNTACTICALLY_EQUAL, taskFactory, taskTreeBuilder),154 new DefaultTaskSequenceDetectionRule155 (NodeEquality.LEXICALLY_EQUAL, taskFactory, taskTreeBuilder),*/156 /*new TreeScopeWrapperRule157 (new DefaultIterationDetectionRule158 (NodeEquality.LEXICALLY_EQUAL, taskFactory, taskTreeBuilder)),159 new TreeScopeWrapperRule160 (new DefaultIterationDetectionRule161 (NodeEquality.SYNTACTICALLY_EQUAL, taskFactory, taskTreeBuilder)),162 new TreeScopeWrapperRule163 (new DefaultIterationDetectionRule164 (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 data182 * is available and, therefore, finalizes the rule application.183 * </p>184 *185 * @param sessions the sessions to be processed186 */187 public void applyRules(List<IUserSession> sessions) {188 applyRules(sessionScopeRules, sessions, "");189 129 } 190 130 … … 197 137 * @param sessions the sessions to be processed 198 138 */ 199 public void applyTaskDetectionRule(List<IUserSession> sessions) { 139 public void applyTaskDetectionRule(List<IUserSession> sessions, 140 TaskEquality minimalTaskEquality, 141 int minimumSequenceCoverage) 142 { 200 143 ISessionScopeRule[] rules = new ISessionScopeRule[] { 201 new SequenceForTaskDetectionRule 202 (TaskEquality.SEMANTICALLY_EQUAL, taskFactory, taskBuilder)144 new SequenceForTaskDetectionRule(minimalTaskEquality, taskFactory, taskBuilder, 145 minimumSequenceCoverage) 203 146 }; 204 147 … … 261 204 262 205 //dumpTask(parent, ""); 263 264 for (ITaskInstance newParent : result.getNewlyCreatedTaskInstances()) {265 noOfRuleApplications +=266 applyRules(taskScopeRules, newParent, logIndent + " ");267 }268 206 } 269 207 } … … 271 209 (result.getRuleApplicationStatus() == RuleApplicationStatus.FINISHED)); 272 210 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, the287 * rule application is finalized as far as possible without waiting for further data. If it is288 * false, the rule application is broken up at the first rule returning, that its application289 * would be feasible. The method calls itself for each parent task created through the rule290 * application. In this case, the finalize parameter is always true.291 * </p>292 *293 * @param parent the parent task to apply the rules on294 * @param finalize used to indicate, if the rule application shall break up if a rule would295 * be feasible if further data was available, or not.296 * @param logIndent simply used for logging purposes to indent the log messages depending297 * 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.traceln311 (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.traceln318 (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));331 211 } 332 212 -
trunk/autoquest-ui-core/src/main/java/de/ugoe/cs/autoquest/commands/usability/CMDgenerateTaskTree.java
r1844 r2132 45 45 @Override 46 46 public String help() { 47 return "generateTaskTree <sequences> {<tasktree>}"; 47 return "generateTaskTree <sequences> {<tasktree>} {-considerEventEquality} " + 48 "{-minimumSequenceCoverage=<some integer>}"; 48 49 } 49 50 … … 56 57 @Override 57 58 public void run(List<Object> parameters) { 58 String sequencesName; 59 String tasktreeName; 59 String sequencesName = null; 60 String tasktreeName = null; 61 boolean useEventEqualityForTaskComparison = false; 62 int minimumSequenceCoverage = 0; 63 60 64 try { 61 sequencesName = (String) parameters.get(0); 62 if (parameters.size() > 1) { 63 tasktreeName = (String) parameters.get(1); 64 } 65 else { 66 tasktreeName = "tasktree"; 65 for (int i = 0; i < parameters.size(); i++) { 66 String parameter = (String) parameters.get(i); 67 if (!parameter.startsWith("-")) { 68 if (sequencesName == null) { 69 sequencesName = parameter; 70 } 71 else if (tasktreeName == null) { 72 tasktreeName = parameter; 73 } 74 else { 75 throw new IllegalArgumentException("unrecognized parameter: " + parameter); 76 } 77 } 78 else { 79 if ("-considerEventEquality".equals(parameter)) { 80 useEventEqualityForTaskComparison = true; 81 } 82 else if (parameter.startsWith("-minimumSequenceCoverage=")) { 83 try { 84 minimumSequenceCoverage = Integer.parseInt 85 (parameter.substring("-minimumSequenceCoverage=".length())); 86 } 87 catch (Exception e) { 88 throw new IllegalArgumentException 89 ("invalid value for parameter minimumSequenceCoverage: " + 90 parameter.substring("-minimumSequenceCoverage=".length())); 91 } 92 } 93 else { 94 throw new IllegalArgumentException("unrecognized parameter: " + parameter); 95 } 96 } 67 97 } 68 98 } 99 catch (IllegalArgumentException e) { 100 throw e; 101 } 69 102 catch (Exception e) { 103 throw new IllegalArgumentException("could not process parameters", e); 104 } 105 106 if (sequencesName == null) { 70 107 throw new IllegalArgumentException("must provide a sequences name"); 108 } 109 110 if (tasktreeName == null) { 111 tasktreeName = "tasktree"; 71 112 } 72 113 … … 84 125 sequences = (Collection<List<Event>>) dataObject; 85 126 86 ITaskModel taskModel = new TaskTreeManager().createTaskModel(sequences); 127 ITaskModel taskModel = new TaskTreeManager().createTaskModel 128 (sequences, useEventEqualityForTaskComparison, minimumSequenceCoverage); 87 129 88 130 if (GlobalDataContainer.getInstance().addData(tasktreeName, taskModel)) { -
trunk/autoquest-ui-core/src/main/resources/manuals/generateTaskTree
r1877 r2132 5 5 <tasktree> name of the object to store the task model in (defaults to "tasktree") 6 6 7 -considerEventEquality 8 to be provided if the events equal method shall be used for event comparison. This can 9 accelerate the comparison process 10 11 -minimumSequenceCoverage=<some integer> 12 can be used to define a minimum number of events that shall be covered by the detected 13 sequences. This prevents the detection of sequences that mainly represent noise. 14 7 15 Example(s) 8 16 generateTaskTree sequences tasktree 17 generateTaskTree sequences -considerEventEquality 18 generateTaskTree sequences tasktree -considerEventEquality -minimumSequenceCoverage=10
Note: See TracChangeset
for help on using the changeset viewer.