只获得Twitter 4J中包含所需单词的推文

时间:2016-10-10 09:09:41

标签: apache-storm twitter4j twitter-streaming-api

// create the twitter stream factory with the config
TwitterStreamFactory fact =
    new TwitterStreamFactory(config.build());

// get an instance of twitter stream
twitterStream = fact.getInstance();

FilterQuery tweetFilterQuery = new FilterQuery(); // See
tweetFilterQuery.locations(new double[][]{new double[]   {-124.848974,24.396308},
                new double[]{-66.885444,49.384358
                }});
tweetFilterQuery.language(new String[]{"en"});
tweetFilterQuery.track(new String[]{"sony", "apple" });

// provide the handler for twitter stream
twitterStream.addListener(new TweetListener());

twitterStream.filter(tweetFilterQuery);

// start the sampling of tweets
//twitterStream.sample();

在twitter spout中我只想要包含apple或sony字样的推文,我尝试过tweetFilterQuery.track()。我只需要包含索尼和苹果字的推文。

0 个答案:

没有答案