@Test public void testExtractCollectsAllHasTags() { Map<String, Long> result = testObj.extract("#Poker bla bla #Casino bla poker blab bla #Casino #Poker #Poker"); assertNotNull(result); assertThat(result, Matchers.allOf(hasEntry(is("#Poker"), is(3L)), Matchers.hasEntry(is("#Casino"), is(2L)))); }
public Map<String, Long> extract(String tweet) { Map<String, Long> tokens = Splitter.on(CharMatcher.INVISIBLE.or(CharMatcher.WHITESPACE .or(CharMatcher.anyOf(";,")))).trimResults().omitEmptyStrings().splitToList(tweet).stream() .filter(token -> token.startsWith("#")) .collect(groupingBy(identity(), counting())); return tokens; }
HashTagExtractor { public Map<String, Long> extract(String tweet) { Map<String, Long> tokens = Splitter.on(CharMatcher.INVISIBLE.or(CharMatcher.WHITESPACE .or(CharMatcher.anyOf(";,")))).trimResults().omitEmptyStrings().splitToList(tweet).stream() .filter(token -> token.startsWith("#")) .collect(groupingBy(identity(), counting())); return tokens; } }
HashTagExtractor { public Map<String, Long> extract(String tweet) { Map<String, Long> tokens = Splitter.on(CharMatcher.INVISIBLE.or(CharMatcher.WHITESPACE .or(CharMatcher.anyOf(";,")))).trimResults().omitEmptyStrings().splitToList(tweet).stream() .filter(token -> token.startsWith("#")) .collect(groupingBy(identity(), counting())); return tokens; }  }
HashTagExtractor { public Map<String, Long> extract(String tweet) { Map<String, Long> tokens = Splitter.on(CharMatcher.INVISIBLE.or(CharMatcher.WHITESPACE .or(CharMatcher.anyOf(";,")))).trimResults().omitEmptyStrings().splitToList(tweet).stream() .filter(token -> token.startsWith("#")) .collect(groupingBy(identity(), counting())); return tokens; }  Map<String, Long> extract(String tweet); }
HashTagExtractor { public Map<String, Long> extract(String tweet) { Map<String, Long> tokens = Splitter.on(CharMatcher.INVISIBLE.or(CharMatcher.WHITESPACE .or(CharMatcher.anyOf(";,")))).trimResults().omitEmptyStrings().splitToList(tweet).stream() .filter(token -> token.startsWith("#")) .collect(groupingBy(identity(), counting())); return tokens; }  Map<String, Long> extract(String tweet);  }