[1040] | 1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany
|
---|
| 2 | //
|
---|
| 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 4 | // you may not use this file except in compliance with the License.
|
---|
| 5 | // You may obtain a copy of the License at
|
---|
| 6 | //
|
---|
| 7 | // http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 8 | //
|
---|
| 9 | // Unless required by applicable law or agreed to in writing, software
|
---|
| 10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 12 | // See the License for the specific language governing permissions and
|
---|
| 13 | // limitations under the License.
|
---|
| 14 |
|
---|
[1030] | 15 | package de.ugoe.cs.autoquest.usability.evaluation.rule.evaluator;
|
---|
| 16 |
|
---|
| 17 | import static de.ugoe.cs.autoquest.usability.tasktree.filter.EventTypeFilter.TEXT_INPUT;
|
---|
| 18 |
|
---|
| 19 | import com.google.common.base.Optional;
|
---|
| 20 | import com.google.common.base.Predicate;
|
---|
| 21 | import com.google.common.collect.Iterables;
|
---|
| 22 |
|
---|
| 23 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree;
|
---|
| 24 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode;
|
---|
| 25 | import de.ugoe.cs.autoquest.usability.evaluation.result.UsabilityDefectSeverityLevel;
|
---|
| 26 | import de.ugoe.cs.autoquest.usability.evaluation.rule.set.UsabilityRule;
|
---|
| 27 | import de.ugoe.cs.autoquest.usability.tasktree.filter.FilterStatistic;
|
---|
| 28 | import de.ugoe.cs.autoquest.usability.tasktree.filter.IterativeDFSFilterStrategy;
|
---|
| 29 | import de.ugoe.cs.autoquest.usability.tasktree.filter.TaskTreeFilter;
|
---|
| 30 |
|
---|
[1040] | 31 | /**
|
---|
| 32 | * <p>
|
---|
| 33 | * TODO comment
|
---|
| 34 | * </p>
|
---|
| 35 | *
|
---|
| 36 | * @author Alexander Deicke
|
---|
| 37 | */
|
---|
[1030] | 38 | public class TextInputRatioEvaluator extends RuleEvaluator {
|
---|
| 39 |
|
---|
| 40 | public TextInputRatioEvaluator(UsabilityRule evaluatedUsabilityRule, ITaskTree taskTree) {
|
---|
| 41 | super(evaluatedUsabilityRule, taskTree);
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | @Override
|
---|
| 45 | protected FilterStatistic nodesUnderEvaluation(ITaskTree taskTree) {
|
---|
| 46 | Optional<FilterStatistic> cachedNodes = loadFromCache(TEXT_INPUT);
|
---|
[1040] | 47 | return cachedNodes.isPresent() ? cachedNodes.get() : cacheAndReturnNodes(taskTree,
|
---|
| 48 | TEXT_INPUT);
|
---|
[1030] | 49 | }
|
---|
| 50 |
|
---|
| 51 | @Override
|
---|
| 52 | protected FilterStatistic extractNodesFromTaskTree(ITaskTree taskTree) {
|
---|
[1040] | 53 | return new TaskTreeFilter(new IterativeDFSFilterStrategy()).filterByEventType(TEXT_INPUT)
|
---|
| 54 | .from(taskTree);
|
---|
[1030] | 55 | }
|
---|
| 56 |
|
---|
| 57 | @Override
|
---|
| 58 | protected float calculateEvaluationMetric() {
|
---|
| 59 | float textInputEvents = this.filteredNodes.nrOfNodesMatchedFilter();
|
---|
| 60 | float nonTextInputEvents = nrOfEventNodesNotMatchedFilter();
|
---|
| 61 | return textInputEvents / (textInputEvents + nonTextInputEvents);
|
---|
| 62 | }
|
---|
[1040] | 63 |
|
---|
[1030] | 64 | private int nrOfEventNodesNotMatchedFilter() {
|
---|
[1040] | 65 | return Iterables.size(Iterables.filter(this.filteredNodes.nodesNotMatchedFilter(),
|
---|
| 66 | new Predicate<ITaskTreeNode>() {
|
---|
| 67 |
|
---|
| 68 | @Override
|
---|
| 69 | public boolean apply(ITaskTreeNode node) {
|
---|
| 70 | return (node.getChildren() == null) ||
|
---|
| 71 | (node.getChildren().size() == 0);
|
---|
| 72 | }
|
---|
| 73 | }));
|
---|
[1030] | 74 | }
|
---|
| 75 |
|
---|
| 76 | @Override
|
---|
[1040] | 77 | protected Optional<UsabilityDefectSeverityLevel> determineSeverityLevel(float evaluationMetric)
|
---|
| 78 | {
|
---|
[1030] | 79 | Optional<UsabilityDefectSeverityLevel> recommendationSeverityLevel = Optional.absent();
|
---|
| 80 | if (evaluationMetric > 0.9) {
|
---|
| 81 | recommendationSeverityLevel = Optional.of(UsabilityDefectSeverityLevel.HIGH);
|
---|
| 82 | }
|
---|
| 83 | else if (evaluationMetric > 0.7) {
|
---|
| 84 | recommendationSeverityLevel = Optional.of(UsabilityDefectSeverityLevel.MEDIUM);
|
---|
| 85 | }
|
---|
| 86 | else if (evaluationMetric > 0.5) {
|
---|
| 87 | recommendationSeverityLevel = Optional.of(UsabilityDefectSeverityLevel.LOW);
|
---|
| 88 | }
|
---|
| 89 | else if (evaluationMetric > 0.3) {
|
---|
| 90 | recommendationSeverityLevel = Optional.of(UsabilityDefectSeverityLevel.INFO);
|
---|
| 91 | }
|
---|
| 92 | return recommendationSeverityLevel;
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | }
|
---|