0
なぜこれが実行されているときに、感情の値によってツイートが消去されているのですか?センチメント値は、cleanDataメソッドが呼び出されていない場合に表示されます。これは、使用されてインポートされているスタンフォードライブラリのためですか?クリーンなデータのつぶやき
public class WhatToThink {
public static void main(String[] args) {
String topic = "Brussels";
ArrayList<String> tweets = TweetManager.getTweets(topic);
NLP.init();
tweets = cleanData(tweets);
for (String tweet : tweets) {
tweets = cleanData(tweets);
System.out.println(tweet + " : " + NLP.findSentiment(tweet));
}
}
public static ArrayList<String> cleanData(ArrayList<String> tweets) {
ArrayList<String> newTweets = new ArrayList<>();
Iterator itr = tweets.iterator();
while (itr.hasNext()) {
String tweet = itr.next().toString();
//convert tweet to lower case
tweet = tweet.toLowerCase();
//remove urls
tweet = tweet.replaceAll("((www\\.[^\\s]+)|(https?://[^\\s]+))", "URL");
//remove user names
tweet = tweet.replaceAll("@[^\\s]+", "ATUSER");
//remove # from hash tag
tweet = tweet.replaceAll("#", "");
//remove punctuation
tweet = tweet.replaceAll("\\p{Punct}+", "");
System.out.println(tweet);
}
return newTweets;
}
}