HashtagEntity[] hts = status.getHashtagEntities(); String text = status.getText(); theMap.put("text", (null == text) ? "" : text);
@Override public void onStatus(Status status) { HashtagEntity[] hashtagEntities = status.getHashtagEntities(); JetstreamEvent event = new JetstreamEvent(); event.setEventType("TwitterSample"); Place place = status.getPlace(); if (place != null) { event.put("country", place.getCountry()); } event.put("ct", status.getCreatedAt().getTime()); event.put("text", status.getText()); event.put("lang", status.getLang()); event.put("user", status.getUser().getName()); if (hashtagEntities != null && hashtagEntities.length > 0) { StringBuilder s = new StringBuilder(); s.append(hashtagEntities[0].getText()); for (int i = 1; i < hashtagEntities.length; i++) { s.append(","); s.append(hashtagEntities[i].getText()); } event.put("hashtag", s.toString()); } fireSendEvent(event); }
@Override public List<Object> filter(Status status) { if(status == null) { return null; } List<HashtagEntity> hashtags = Arrays.asList(status.getHashtagEntities()); if(hashtags != null && hashtags.size() > 0) { for(HashtagEntity tag: hashtags) { if(!forbiddenTags.contains(tag.getText().toLowerCase())) { publish(tag.getText().toLowerCase()); } } } return null; }
@Override public void process(Status status) { HashtagEntity[] entities = status.getHashtagEntities(); if (entities != null) { for (HashtagEntity he : entities) { if (he != null) { hashtags.emit(he.getText()); } } } }
@Override public List<Context> apply(Status in) { HashtagEntity[] tags = in.getHashtagEntities(); List<Context> ret = new ArrayList<Context>(); for (HashtagEntity hashtagEntity : tags) { String withHash = "#" + hashtagEntity.getText(); if(hashes.contains(withHash)){ Context ctx = new Context(); ctx.put(HASHTAG_KEY, withHash); ctx.put("status", in); ret.add(ctx); } } return ret; }
private void extractHashtags(Status tweet, Set<Content> contents) { for (HashtagEntity entity : tweet.getHashtagEntities()) { Content hashtag = newBase(tweet); String hashtag_normalized = entity.getText().toLowerCase(); hashtag.setContentName(hashtag_normalized); hashtag.setContentType("hashtag"); contents.add(hashtag); } }
@Override public List<Context> apply(Status in) { HashtagEntity[] tags = in.getHashtagEntities(); List<Context> ret = new ArrayList<Context>(); for (HashtagEntity hashtagEntity : tags) { String withHash = "#" + hashtagEntity.getText(); if(hashes.contains(withHash)){ Context ctx = new Context(); ctx.put(HASHTAG_KEY, withHash); ctx.put("status", in); ret.add(ctx); } } return ret; }
@Override public List<Token> extractTokens(final Status status) { return Arrays.stream(status.getHashtagEntities()).map(hashtag -> new Token( "#" + hashtag.getText(), hashtag.getStart(), hashtag.getEnd(), Token.TokenType.CLICKABLE, () -> browserSupport.openUrl(HASHTAG_SEARCH_BASE_URL + hashtag.getText()) )).collect(Collectors.toList()); }
for(HashtagEntity hashtagEntity: status.getHashtagEntities())
@Override public void execute(Tuple tuple) { Status status = (Status)tuple.getValue(0); HashtagEntity hashTags[] = status.getHashtagEntities(); if(hashTags != null && hashTags.length >=2) { int count = 0; /** * Do simple filtering to remove spam tweets */ for(HashtagEntity hashtag: hashTags) { if("android".equals(hashtag.getText().toLowerCase()) || "androidgames".equals(hashtag.getText().toLowerCase())) { count++; } } if(count == 2) { return; } } collector.emit(tuple, new Values(status)); collector.ack(tuple); }
HashtagEntity[] hts = status.getHashtagEntities(); String text = status.getText(); theMap.put("text", (null == text) ? "" : text);
long tweetId = status.getId(); long resolvedTweetId = status.isRetweet() ? status.getRetweetedStatus().getId() : status.getId(); HashtagEntity[] hashtagEntities = status.getHashtagEntities();
HashtagEntity[] hashtagsEntities = tweetById.getHashtagEntities(); for (HashtagEntity hashtag : hashtagsEntities){ System.out.println(hashtag.getText());
@Override public void emitTuples() { for (int size = statuses.size(); size-- > 0;) { Status s = statuses.poll(); if (status.isConnected()) { status.emit(s); } if (text.isConnected()) { text.emit(s.getText()); } if (url.isConnected()) { URLEntity[] entities = s.getURLEntities(); if (entities != null) { for (URLEntity ue : entities) { url.emit((ue.getExpandedURL() == null ? ue.getURL() : ue.getExpandedURL()).toString()); } } } if (hashtag.isConnected()) { HashtagEntity[] hashtagEntities = s.getHashtagEntities(); if (hashtagEntities != null) { for (HashtagEntity he : hashtagEntities) { hashtag.emit(he.getText()); } } } } }
@Override public void emitTuples() { for (int size = statuses.size(); size-- > 0;) { Status s = statuses.poll(); if (status.isConnected()) { status.emit(s); } if (text.isConnected()) { text.emit(s.getText()); } if (url.isConnected()) { URLEntity[] entities = s.getURLEntities(); if (entities != null) { for (URLEntity ue : entities) { url.emit((ue.getExpandedURL() == null ? ue.getURL() : ue.getExpandedURL()).toString()); } } } if (hashtag.isConnected()) { HashtagEntity[] hashtagEntities = s.getHashtagEntities(); if (hashtagEntities != null) { for (HashtagEntity he : hashtagEntities) { hashtag.emit(he.getText()); } } } } }
if (tweet.getHashtagEntities() != null) { extractHashtags(tweet, contents);
for (final HashtagEntity tag : this.status.getHashtagEntities()) { status.keywords.add(tag.getText());
for (final HashtagEntity tag : this.status.getHashtagEntities()) { status.keywords.add(tag.getText());
struct.put("HashtagEntities", convert(status.getHashtagEntities())); struct.put("UserMentionEntities", convert(status.getUserMentionEntities())); struct.put("MediaEntities", convert(status.getMediaEntities()));