本文整理汇总了Java中org.springframework.social.twitter.api.Tweet类的典型用法代码示例。如果您正苦于以下问题:Java Tweet类的具体用法?Java Tweet怎么用?Java Tweet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Tweet类属于org.springframework.social.twitter.api包,在下文中一共展示了Tweet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: processTweet
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
private void processTweet(Tweet tweet) {
String lang = tweet.getLanguageCode();
//String text = tweet.getText();
// filter non-English tweets:
if (!"en".equals(lang)) {
return;
}
//Set<String> hashTags = hashTagsFromTweet(text);
// filter tweets without hashtags:
// if (hashTags.isEmpty()) {
// return;
// }
log.info("\n Tweet: " + tweet.getText() + "\n");
dataService.saveTweet(tweet);
}
开发者ID:thinksky-sourcecode,项目名称:microservices-prototype,代码行数:21,代码来源:TweetProcessor.java
示例2: news
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/news")
public Map<Tweet, String> news() throws InvalidInputException {
List<Trend> someTrends = trendSearch.getTrends(1);
Map<Tweet, String> allClassification = new HashMap<>();
for (Trend iterator : someTrends) {
List<Tweet> tweets = twitterScrape.scrape(iterator.getName());
for (Tweet iteratorTweet : tweets) {
if (iteratorTweet.getLanguageCode().equals("en") == true) {
String classification = new Request().classify(iteratorTweet);
allClassification.put(iteratorTweet, classification);
}
}
}
return allClassification;
}
开发者ID:cipriancus,项目名称:FakeTwitterDetection,代码行数:22,代码来源:RestApi.java
示例3: tweets
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
@Bean
CommandLineRunner tweets(Logger logger, TwitterTemplate twitterTemplate, JdbcTemplate jdbcTemplate) {
return args -> {
String screenName = "hintjens";
int pageSize = 200;
List<Tweet> userTimeline = twitterTemplate.timelineOperations()
.getUserTimeline(screenName, pageSize);
long maxId;
while (userTimeline.size() != 0 ) {
maxId = userTimeline.stream()
.map(Tweet::getId)
.reduce((tweet, tweet2) -> tweet < tweet2 ? tweet : tweet2)
.orElse(0L);
userTimeline = twitterTemplate.timelineOperations()
.getUserTimeline(screenName, pageSize, 0L, maxId - 1);
addAllTweets(jdbcTemplate, userTimeline);
logger.info("added " + userTimeline.size() + " records.");
}
};
}
开发者ID:joshlong,项目名称:hintjens-tweets,代码行数:21,代码来源:HintjensApplication.java
示例4: save
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
private TweetEntity save(final Tweet tweetEntity, final UserEntity user) {
TweetEntity tweet = new TweetEntity();
tweet.setCreatedAt(tweetEntity.getCreatedAt());
tweet.setLanguageCode(tweetEntity.getLanguageCode());
tweet.setSource(tweetEntity.getSource());
tweet.setText(tweetEntity.getText());
tweet.setUser(user);
if (tweetRepository != null) {
tweet = tweetRepository.save(tweet);
System.out.println(tweetEntity.getText());
return tweet;
}
return null;
}
开发者ID:ivanvs,项目名称:elasticsearch-spring-demo,代码行数:17,代码来源:TweetService.java
示例5: searchTwitter
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
@GetMapping(path = "tweet")
public String searchTwitter(Model model, @RequestParam String search) {
int count = 200;
SearchResults results = twitterTemplate.searchOperations().search(
new SearchParameters(search)
.resultType(SearchParameters.ResultType.RECENT)
.count(count));
List<Tweet> tweets = results.getTweets();
model.addAttribute("tweets", tweets);
model.addAttribute("count", count);
model.addAttribute("search", search);
return "search";
}
开发者ID:RawSanj,项目名称:spring-twitter-stream,代码行数:18,代码来源:SearchController.java
示例6: storeUserTimelinePiece
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
@Transactional
public TimelineMusic storeUserTimelinePiece(User user) {
if (user == null) {
return null;
}
SocialAuthentication auth = userDao.getTwitterAuthentication(user);
if (auth == null) {
return null;
}
Twitter twitter = provider.getApi(auth.getToken(), auth.getSecret());
List<Tweet> tweets = twitter.timelineOperations().getUserTimeline(200);
TimelineMusic meta = getUserTimelinePiece(tweets);
meta.setTwitterHandle(twitter.userOperations().getScreenName());
meta.setUser(user);
meta = pieceDao.persist(meta);
return meta;
}
开发者ID:Glamdring,项目名称:computoser,代码行数:23,代码来源:TimelineToMusicService.java
示例7: getTempo
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
/**
* Gets the tempo, depending on the rate of tweeting
*
* @param tweets
* @return tempo
*/
private Tempo getTempo(List<Tweet> tweets, TimelineMusic meta) {
long totalSpacingInMillis = 0;
Tweet previousTweet = null;
for (Tweet tweet : tweets) {
if (previousTweet != null) {
totalSpacingInMillis += Math.abs(previousTweet.getCreatedAt().getTime() - tweet.getCreatedAt().getTime());
}
previousTweet = tweet;
}
double averageSpacing = totalSpacingInMillis / (tweets.size() - 1);
meta.setAverageSpacing(averageSpacing);
if (averageSpacing > 3 * DateTimeConstants.MILLIS_PER_DAY) { //once every three days
return Tempo.VERY_SLOW;
} else if (averageSpacing > 1.5 * DateTimeConstants.MILLIS_PER_DAY) { // more than once every 1.5 days
return Tempo.SLOW;
} else if (averageSpacing > 16 * DateTimeConstants.MILLIS_PER_HOUR) { // more than once every 16 hours
return Tempo.MEDIUM;
} else if (averageSpacing > 4 * DateTimeConstants.MILLIS_PER_HOUR) { // more than once every 4 hours
return Tempo.FAST;
} else {
return Tempo.VERY_FAST;
}
}
开发者ID:Glamdring,项目名称:computoser,代码行数:32,代码来源:TimelineToMusicService.java
示例8: getScale
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
/**
* Sentiment determines major or minor scale (or lydian/dorian ~= neutral)
* Average length of tweets determines pentatonic or heptatonic
*
* @param tweets
* @return scale
*/
private Scale getScale(List<Tweet> tweets, TimelineMusic meta) {
Set<String> documents = new HashSet<>();
for (Tweet tweet : tweets) {
documents.add(tweet.getText());
}
SentimentResult sentiment = sentimentAnalyzer.getSentiment(documents, meta);
double totalLength = 0;
for (String document : documents) {
totalLength += document.length();
}
double averageLength = totalLength / documents.size();
meta.setSentiment(sentiment);
meta.setAverageLength(averageLength);
if (sentiment == SentimentResult.POSITIVE) {
return averageLength < 40 ? Scale.MAJOR_PENTATONIC : Scale.MAJOR;
} else if (sentiment == SentimentResult.NEGATIVE) {
return averageLength < 40 ? Scale.MINOR_PENTATONIC : Scale.MINOR;
}
// choose rarer scales for neutral tweets
return Chance.test(50) ? Scale.LYDIAN : Scale.DORIAN;
}
开发者ID:Glamdring,项目名称:computoser,代码行数:32,代码来源:TimelineToMusicService.java
示例9: run
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
@Override
public void run() {
while (true) {
try {
Tweet tweet = queue.take();
processTweet(tweet);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
开发者ID:thinksky-sourcecode,项目名称:microservices-prototype,代码行数:12,代码来源:TweetProcessor.java
示例10: getUserTimeline
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
/**
*
* @param twitterUser
* @return
*/
public List <Tweet> getUserTimeline(String twitterUser) {
TimelineOperations timelineOps = twitter.timelineOperations();
List<Tweet> tweets = timelineOps.getUserTimeline("@" + twitterUser);
return tweets;
}
开发者ID:tspannhw,项目名称:hive,代码行数:12,代码来源:TwitterService.java
示例11: scrape
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
public List<Tweet> scrape(String term) throws InvalidInputException{
if(term == null || term.length()==0)
throw new InvalidInputException();
List<Tweet> tweetList = twitterTemplate.searchOperations().search(term).getTweets();
tweetList.forEach(tweetEntity -> {
twitter.entity.Tweet tweet = new twitter.entity.Tweet();
tweet.setText(tweetEntity.getText());
tweetService.save(tweet);
});
return tweetList;
}
开发者ID:cipriancus,项目名称:FakeTwitterDetection,代码行数:14,代码来源:TwitterScrape.java
示例12: classify
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
public String classify(Tweet tweet) {
MultiValueMap<String, String> allArguments= new LinkedMultiValueMap<>();
allArguments.add("Date", tweet.getCreatedAt().toString());
allArguments.add("Tweet_Text", tweet.getText());
allArguments.add("Tweet_Id", tweet.getIdStr());
allArguments.add("User_Id", Long.toString(tweet.getFromUserId()));
allArguments.add("User_Name", tweet.getUser().getName());
allArguments.add("User_Screen_Name", tweet.getUser().getScreenName());
allArguments.add("Retweets", Integer.toString(tweet.getRetweetCount()));
allArguments.add("Favorites", Integer.toString(tweet.getFavoriteCount()));
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<MultiValueMap<String, String>>(allArguments, headers);
ResponseEntity<String> response = restTemplate.postForEntity( requestURL, request , String.class );
return response.getBody();
}
开发者ID:cipriancus,项目名称:FakeTwitterDetection,代码行数:22,代码来源:Request.java
示例13: search
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("/tweets/{tweetTerm}")
public List<Tweet> search(@PathParam("tweetTerm") String tweetTerm) {
List<Tweet> tweetList = null;
try {
tweetList = twitterScrape.scrape(tweetTerm);
} catch (InvalidInputException e) {
e.printStackTrace();
}
return tweetList;
}
开发者ID:cipriancus,项目名称:FakeTwitterDetection,代码行数:13,代码来源:RestApi.java
示例14: trendSearchAndScrapeWithSentiment_tweetIsNull_ShouldThrowException
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
@Test(expected = InvalidInputException.class)
public final void trendSearchAndScrapeWithSentiment_tweetIsNull_ShouldThrowException() throws InvalidInputException {
List<Trend> trends = trendSearch.getTrends(WORLD_WOEID).subList(0, 10);
assertNotNull(trends);
for (Trend trend : trends) {
List<Tweet> tweets = twitterScrape.scrape(trend.getName()).subList(0, 10);
assertNotNull(tweets);
for (Tweet tweet : tweets) {
int sentiment = sentimentAnalysis.calculateSentiment(null);
}
}
}
开发者ID:cipriancus,项目名称:FakeTwitterDetection,代码行数:15,代码来源:TrendScrapeSentimentIntegrationTest.java
示例15: trendSearchAndScrape
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
@Test
public final void trendSearchAndScrape() throws InvalidInputException {
List<Trend> trends = trendSearch.getTrends(WORLD_WOEID).subList(0, 5);//get some trends
assertNotNull(trends);
for (Trend trend : trends) {
List<Tweet> tweets = twitterScrape.scrape(trend.getName()).subList(0, 5);
assertNotNull(tweets);
}
}
开发者ID:cipriancus,项目名称:FakeTwitterDetection,代码行数:10,代码来源:TrendScrapeIntegrationTest.java
示例16: search
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
@Override
@HystrixCommand(commandKey = "GetTweets", fallbackMethod = "noResults", commandProperties = {
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "5000")
})
public Collection<String> search(String q, int pageSize) {
SearchResults results = twitter.searchOperations().search(q, pageSize);
return results.getTweets().stream()
.map(Tweet::getUnmodifiedText)
.collect(toSet());
}
开发者ID:qaware,项目名称:hitchhikers-guide-cloudnative,代码行数:11,代码来源:ZwitscherRepositoryImpl.java
示例17: Response
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
public Response(SearchResults results, int count) {
for (int i = 0; i < results.getTweets().size(); i++) {
if (statuses == null) this.statuses = new ArrayList<Tweet>();
this.statuses.add(results.getTweets().get(i));
if (i >= count - 1) break;
}
search_metadata = results.getSearchMetadata();
}
开发者ID:sapmentors,项目名称:lemonaid,代码行数:9,代码来源:Tweets.java
示例18: processTweet
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
@Override
@Transactional
public void processTweet(final Tweet tweetEntity) {
final UserEntity user = findOrCreate(tweetEntity.getUser());
if (user != null) {
save(tweetEntity, user);
}
saveEs(tweetEntity);
}
开发者ID:ivanvs,项目名称:elasticsearch-spring-demo,代码行数:13,代码来源:TweetService.java
示例19: saveEs
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
private TweetEsEntity saveEs(final Tweet tweetEntity) {
final TwitterProfile twitterProfile = tweetEntity.getUser();
final UserEsEntity user = new UserEsEntity();
user.setCreatedDate(twitterProfile.getCreatedDate());
user.setDescription(twitterProfile.getDescription());
user.setLocation(twitterProfile.getLocation());
user.setName(twitterProfile.getName());
user.setProfileUrl(twitterProfile.getProfileUrl());
user.setProfilImageUrl(twitterProfile.getProfileImageUrl());
user.setScreenName(twitterProfile.getScreenName());
user.setTwitterId(twitterProfile.getId() + "");
TweetEsEntity esTweet = new TweetEsEntity();
esTweet.setCreatedAt(tweetEntity.getCreatedAt());
esTweet.setLanguageCode(tweetEntity.getLanguageCode());
esTweet.setSource(tweetEntity.getSource());
esTweet.setText(tweetEntity.getText());
esTweet.setUser(user);
if (tweetEsRepository != null) {
esTweet = tweetEsRepository.save(esTweet);
return esTweet;
}
return null;
}
开发者ID:ivanvs,项目名称:elasticsearch-spring-demo,代码行数:28,代码来源:TweetService.java
示例20: run
import org.springframework.social.twitter.api.Tweet; //导入依赖的package包/类
@Override
public void run() {
while (true) {
try {
final Tweet tweet = queue.take();
processTweet(tweet);
} catch (final InterruptedException e) {
e.printStackTrace();
}
}
}
开发者ID:ivanvs,项目名称:elasticsearch-spring-demo,代码行数:12,代码来源:TweetProcessor.java
注:本文中的org.springframework.social.twitter.api.Tweet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论