Search in sources :

Example 1 with MarkTool

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);
}
Also used : WordFilter(io.github.vocabhunter.analysis.filter.WordFilter) MarkTool(io.github.vocabhunter.analysis.marked.MarkTool)

Example 2 with MarkTool

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);
    }
}
Also used : WordFilter(io.github.vocabhunter.analysis.filter.WordFilter) VocabHunterException(io.github.vocabhunter.analysis.core.VocabHunterException) MarkTool(io.github.vocabhunter.analysis.marked.MarkTool)

Aggregations

WordFilter (io.github.vocabhunter.analysis.filter.WordFilter)2 MarkTool (io.github.vocabhunter.analysis.marked.MarkTool)2 VocabHunterException (io.github.vocabhunter.analysis.core.VocabHunterException)1