use of io.github.vocabhunter.analysis.marked.MarkTool in project VocabHunter by VocabHunter.
the class SessionWordsToolTest method validate.
private void validate(final Function<Path, List<String>> filterMethod, final List<String> expected) throws Exception {
WordFilter filter = buildFilter(filterMethod);
List<? extends MarkedWord> words = read(SESSION_FILE);
MarkTool<? extends MarkedWord> markTool = new MarkTool<>(filter, words);
List<? extends MarkedWord> shownWords = markTool.getShownWords();
List<String> actual = shownWords.stream().map(MarkedWord::getWordIdentifier).collect(toList());
assertEquals("Filtered words", expected, actual);
}
use of io.github.vocabhunter.analysis.marked.MarkTool in project VocabHunter by VocabHunter.
the class SessionController method updateWordList.
private void updateWordList() {
boolean isEditable = sessionModel.isEditable();
FilterSettings filterSettings = sessionModel.getFilterSettings();
boolean isFilterEnabled = sessionModel.isEnableFilters();
VocabHunterException exception;
boolean isFilterSuccess;
try {
WordFilter filter = filterSettingsTool.filter(filterSettings, isFilterEnabled);
MarkTool<WordModel> markTool = new MarkTool<>(filter, sessionModel.getAllWords());
isFilterSuccess = markTool.isValidFilter();
if (isFilterSuccess) {
sessionModel.updateWordList(isEditable, markTool);
wordListHandler.selectClosestWord(isEditable, filter);
}
exception = null;
} catch (final VocabHunterException e) {
LOG.error("Failed to activate filter", e);
exception = e;
isFilterSuccess = false;
}
if (!isFilterSuccess) {
processFilterFailure(exception);
}
}
Aggregations