Search in sources :

Example 1 with AnalysisResult

use of io.github.vocabhunter.analysis.model.AnalysisResult in project VocabHunter by VocabHunter.

the class FileStreamer method analyse.

public AnalysisResult analyse(final Path file) {
    Instant start = Instant.now();
    List<String> stream = lines(file);
    String filename = FileNameTool.filename(file);
    AnalysisResult result = analyser.analyse(stream, filename);
    int count = result.getOrderedUses().size();
    Instant end = Instant.now();
    Duration duration = Duration.between(start, end);
    LOG.info("Analysed text and found {} words in {}ms ({})", count, duration.toMillis(), filename);
    return result;
}
Also used : Instant(java.time.Instant) Duration(java.time.Duration) AnalysisResult(io.github.vocabhunter.analysis.model.AnalysisResult)

Example 2 with AnalysisResult

use of io.github.vocabhunter.analysis.model.AnalysisResult in project VocabHunter by VocabHunter.

the class SimpleAnalyserTest method testMixedCase.

@Test
public void testMixedCase() {
    AnalysisResult result = analyse(UPPER_CASE, LOWER_CASE);
    validate(result, use(LOWER_CASE, 2, LineReference.FIRST, LineReference.SECOND));
}
Also used : AnalysisResult(io.github.vocabhunter.analysis.model.AnalysisResult) Test(org.junit.jupiter.api.Test)

Example 3 with AnalysisResult

use of io.github.vocabhunter.analysis.model.AnalysisResult in project VocabHunter by VocabHunter.

the class SimpleAnalyserTest method testSpanish.

@Test
public void testSpanish() {
    AnalysisResult result = analyse(LINE_WITH_ACCENTS);
    validate(result, use(SPANISH_1, 1, LineReference.FIRST), use(SPANISH_2, 1, LineReference.FIRST), use(SPANISH_4, 1, LineReference.FIRST), use(SPANISH_3, 1, LineReference.FIRST));
}
Also used : AnalysisResult(io.github.vocabhunter.analysis.model.AnalysisResult) Test(org.junit.jupiter.api.Test)

Example 4 with AnalysisResult

use of io.github.vocabhunter.analysis.model.AnalysisResult in project VocabHunter by VocabHunter.

the class SimpleAnalyserTest method testExtraSpaces.

@Test
public void testExtraSpaces() {
    AnalysisResult result = analyse(LINE_WITH_SPACES);
    validate(result, use(WORD_1, 1, LineReference.FIRST), use(WORD_3, 1, LineReference.FIRST), use(WORD_2, 1, LineReference.FIRST));
}
Also used : AnalysisResult(io.github.vocabhunter.analysis.model.AnalysisResult) Test(org.junit.jupiter.api.Test)

Example 5 with AnalysisResult

use of io.github.vocabhunter.analysis.model.AnalysisResult in project VocabHunter by VocabHunter.

the class SimpleAnalyserTest method testSingle.

@Test
public void testSingle() {
    AnalysisResult result = analyse(WORD_1);
    validate(result, use(WORD_1, 1, LineReference.FIRST));
}
Also used : AnalysisResult(io.github.vocabhunter.analysis.model.AnalysisResult) Test(org.junit.jupiter.api.Test)

Aggregations

AnalysisResult (io.github.vocabhunter.analysis.model.AnalysisResult)14 Test (org.junit.jupiter.api.Test)12 FileStreamer (io.github.vocabhunter.analysis.file.FileStreamer)1 WordFilter (io.github.vocabhunter.analysis.filter.WordFilter)1 SimpleAnalyser (io.github.vocabhunter.analysis.simple.SimpleAnalyser)1 Path (java.nio.file.Path)1 Duration (java.time.Duration)1 Instant (java.time.Instant)1