// choose rarer scales for neutral tweets
return Chance.test(50) ? Scale.LYDIAN : Scale.DORIAN;
}
private Variation getVariation(List<Tweet> tweets, TimelineMusic meta) {
Morphology morphology = new Morphology(new StringReader(""));
Multiset<String> words = HashMultiset.create();
for (Tweet tweet : tweets) {
String tweetText = tweet.getText().toLowerCase();
List<String> urls = TimelineToMusicService.extractUrls(tweetText);
for (String url : urls) {
tweetText = tweetText.replace(url, "");
}
List<String> usernames = TimelineToMusicService.extractMentionedUsernames(tweetText);
for (String username : usernames) {
tweetText = tweetText.replace(username, "").replace("rt", "");
}
String[] wordsInTweet = tweetText.split("[^\\p{L}&&[^']]+");
for (String word : wordsInTweet) {
try {
words.add(morphology.stem(word));
} catch (Exception ex) {
words.add(word);
}
}
}