source: autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/rule/evaluator/TextInputRatioEvaluator.java @ 1030

Last change on this file since 1030 was 1030, checked in by adeicke, 11 years ago

Initial commit.

  • Property svn:mime-type set to text/plain
File size: 3.0 KB
Line 
1package de.ugoe.cs.autoquest.usability.evaluation.rule.evaluator;
2
3import static de.ugoe.cs.autoquest.usability.tasktree.filter.EventTypeFilter.TEXT_INPUT;
4
5import com.google.common.base.Optional;
6import com.google.common.base.Predicate;
7import com.google.common.collect.Iterables;
8
9import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree;
10import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode;
11import de.ugoe.cs.autoquest.usability.evaluation.result.UsabilityDefectSeverityLevel;
12import de.ugoe.cs.autoquest.usability.evaluation.rule.set.UsabilityRule;
13import de.ugoe.cs.autoquest.usability.tasktree.filter.FilterStatistic;
14import de.ugoe.cs.autoquest.usability.tasktree.filter.IterativeDFSFilterStrategy;
15import de.ugoe.cs.autoquest.usability.tasktree.filter.TaskTreeFilter;
16
17public class TextInputRatioEvaluator extends RuleEvaluator {
18
19    public TextInputRatioEvaluator(UsabilityRule evaluatedUsabilityRule, ITaskTree taskTree) {
20        super(evaluatedUsabilityRule, taskTree);
21    }
22
23    @Override
24    protected FilterStatistic nodesUnderEvaluation(ITaskTree taskTree) {
25        Optional<FilterStatistic> cachedNodes = loadFromCache(TEXT_INPUT);
26        return cachedNodes.isPresent() ? cachedNodes.get() : cacheAndReturnNodes(taskTree, TEXT_INPUT);
27    }
28
29    @Override
30    protected FilterStatistic extractNodesFromTaskTree(ITaskTree taskTree) {
31        return new TaskTreeFilter(new IterativeDFSFilterStrategy()).filterByEventType(TEXT_INPUT).from(taskTree);
32    }
33
34    @Override
35    protected float calculateEvaluationMetric() {
36        float textInputEvents = this.filteredNodes.nrOfNodesMatchedFilter();
37        float nonTextInputEvents = nrOfEventNodesNotMatchedFilter();
38        return textInputEvents / (textInputEvents + nonTextInputEvents);
39    }
40   
41    private int nrOfEventNodesNotMatchedFilter() {
42        return Iterables.size(
43            Iterables.filter(this.filteredNodes.nodesNotMatchedFilter(), new Predicate<ITaskTreeNode>() {
44           
45                @Override
46                public boolean apply(ITaskTreeNode node) {
47                    return  (node.getChildren() == null) || (node.getChildren().size() == 0);
48                }
49            })
50        );
51    }
52
53    @Override
54    protected Optional<UsabilityDefectSeverityLevel> determineSeverityLevel(float evaluationMetric) {
55        Optional<UsabilityDefectSeverityLevel> recommendationSeverityLevel = Optional.absent();
56        if (evaluationMetric > 0.9) {
57            recommendationSeverityLevel = Optional.of(UsabilityDefectSeverityLevel.HIGH);
58        }
59        else if (evaluationMetric > 0.7) {
60            recommendationSeverityLevel = Optional.of(UsabilityDefectSeverityLevel.MEDIUM);
61        }
62        else if (evaluationMetric > 0.5) {
63            recommendationSeverityLevel = Optional.of(UsabilityDefectSeverityLevel.LOW);
64        }
65        else if (evaluationMetric > 0.3) {
66            recommendationSeverityLevel = Optional.of(UsabilityDefectSeverityLevel.INFO);
67        }
68        return recommendationSeverityLevel;
69    }
70
71}
Note: See TracBrowser for help on using the repository browser.