Changeset 1040 for trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/util/TextInputUtil.java
- Timestamp:
- 01/16/13 17:51:51 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/util/TextInputUtil.java
r1031 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.util; 2 16 … … 15 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 16 30 31 /** 32 * <p> 33 * TODO comment 34 * </p> 35 * 36 * @author Alexander Deicke 37 */ 17 38 public class TextInputUtil { 18 19 public static Multiset<String> aggregateEnteredTextFromTextInputs(List<ITaskTreeNode> nodesWithTextInputEvents) { 39 40 private TextInputUtil() { 41 // util class 42 } 43 44 public static Multiset<String> aggregateEnteredTextFromTextInputs(List<ITaskTreeNode> nodesWithTextInputEvents) 45 { 20 46 List<Iterable<String>> allTextInputs = Lists.newArrayList(); 21 for (ITaskTreeNode nodeWithTextInput : nodesWithTextInputEvents) {47 for (ITaskTreeNode nodeWithTextInput : nodesWithTextInputEvents) { 22 48 TextInput textInput = (TextInput) ((IEventTask) nodeWithTextInput).getEventType(); 23 49 allTextInputs.add(splitTextIntoWordsAndSigns(textInput.getEnteredText())); … … 25 51 return HashMultiset.create(Iterables.concat(allTextInputs)); 26 52 } 27 53 28 54 public static Iterable<String> splitTextIntoWordsAndSigns(String enteredText) { 29 CharMatcher onlyWords = CharMatcher.WHITESPACE.or(CharMatcher.forPredicate(characterIsJavaIdentifierPartPredicate())); 30 CharMatcher onlySigns = CharMatcher.WHITESPACE.or(CharMatcher.forPredicate(characterIsJavaIdentifierPartPredicate()).negate()); 31 Iterable<String> words = Splitter.on(onlyWords).omitEmptyStrings().trimResults().split(enteredText); 32 Iterable<String> signs = Splitter.on(onlySigns).omitEmptyStrings().trimResults().split(enteredText); 55 CharMatcher onlyWords = 56 CharMatcher.WHITESPACE.or(CharMatcher 57 .forPredicate(characterIsJavaIdentifierPartPredicate())); 58 CharMatcher onlySigns = 59 CharMatcher.WHITESPACE.or(CharMatcher 60 .forPredicate(characterIsJavaIdentifierPartPredicate()).negate()); 61 Iterable<String> words = 62 Splitter.on(onlyWords).omitEmptyStrings().trimResults().split(enteredText); 63 Iterable<String> signs = 64 Splitter.on(onlySigns).omitEmptyStrings().trimResults().split(enteredText); 33 65 return Iterables.concat(words, signs); 34 66 } 35 67 36 68 public static Predicate<Character> characterIsJavaIdentifierPartPredicate() { 37 69 return new Predicate<Character>() { 38 70 39 71 @Override 40 72 public boolean apply(Character character) { 41 return!Character.isJavaIdentifierPart(character);73 return !Character.isJavaIdentifierPart(character); 42 74 } 43 75 44 76 }; 45 77 } 46 78 47 79 public static Predicate<Character> characterIsLetterOrDigitPredicate() { 48 80 return new Predicate<Character>() { 49 81 50 82 @Override 51 83 public boolean apply(Character character) { 52 84 return !Character.isLetterOrDigit(character); 53 85 } 54 86 55 87 }; 56 88 }
Note: See TracChangeset
for help on using the changeset viewer.