### Question:
FrequencyAnalyzer { public List<WordFrequency> load(final InputStream inputStream) throws IOException { return load(IOUtils.readLines(inputStream, characterEncoding)); } FrequencyAnalyzer(); List<WordFrequency> load(final InputStream inputStream); List<WordFrequency> load(final File file); List<WordFrequency> load(final String filePath); List<WordFrequency> load(final URL url); List<WordFrequency> load(final List<String> texts); List<WordFrequency> load(final InputStream inputStream, boolean autoFill, String autoFillWord); List<WordFrequency> load(final InputStream inputStream, boolean autoFill); List<WordFrequency> load(final List<String> texts, boolean autoFill); List<WordFrequency> load(final List<String> texts, boolean autoFill, String autoFillWord); List<WordFrequency> loadWordFrequencies(final List<WordFrequency> wordFrequencies); void setStopWords(final Collection<String> stopWords); void setWordFrequenciesToReturn(final int wordFrequenciesToReturn); void setMinWordLength(final int minWordLength); void setMaxWordLength(final int maxWordLength); void setWordTokenizer(final WordTokenizer wordTokenizer); void clearFilters(); void addFilter(final Filter filter); void setFilter(final Filter filter); void clearNormalizers(); void addNormalizer(final Normalizer normalizer); void setNormalizer(final Normalizer normalizer); void setCharacterEncoding(final String characterEncoding); void setUrlLoadTimeout(final long urlLoadTimeout); static final String DEFAULT_ENCODING; static final int DEFAULT_WORD_MAX_LENGTH; static final int DEFAULT_WORD_MIN_LENGTH; static final int DEFAULT_WORD_FREQUENCIES_TO_RETURN; static final long DEFAULT_URL_LOAD_TIMEOUT; }### Answer:
@Test public void defaultTokenizerTrim() throws IOException { final FrequencyAnalyzer frequencyAnalyzer = new FrequencyAnalyzer(); final List<WordFrequency> wordFrequencies = frequencyAnalyzer.load( Thread.currentThread().getContextClassLoader().getResourceAsStream("trim_test.txt")); final Map<String, WordFrequency> wordFrequencyMap = wordFrequencies .stream() .collect(Collectors.toMap(WordFrequency::getWord, Function.identity())); assertEquals(2, wordFrequencyMap.get("random").getFrequency()); assertEquals(1, wordFrequencyMap.get("some").getFrequency()); assertEquals(1, wordFrequencyMap.get("with").getFrequency()); assertEquals(1, wordFrequencyMap.get("spaces").getFrequency()); assertEquals(1, wordFrequencyMap.get("i'm").getFrequency()); }
@Test public void largeTextFileTest() throws IOException { final FrequencyAnalyzer frequencyAnalyzer = new FrequencyAnalyzer(); final List<WordFrequency> wordFrequencies = frequencyAnalyzer.load( Thread.currentThread().getContextClassLoader().getResourceAsStream("text/simplymeasured.txt")); final Map<String, WordFrequency> wordFrequencyMap = wordFrequencies .stream() .collect(Collectors.toMap(WordFrequency::getWord, Function.identity())); assertEquals(17336, wordFrequencyMap.get("the").getFrequency()); assertEquals(12574, wordFrequencyMap.get("@simplymeasured").getFrequency()); assertEquals(7187, wordFrequencyMap.get("and").getFrequency()); assertEquals(5815, wordFrequencyMap.get("simply").getFrequency()); assertEquals(5755, wordFrequencyMap.get("you").getFrequency()); assertEquals(5501, wordFrequencyMap.get("measured").getFrequency()); assertEquals(3733, wordFrequencyMap.get("instagram").getFrequency()); }