com.twitter
Class Extractor

java.lang.Object
  extended by com.twitter.Extractor

public class Extractor
extends java.lang.Object

A class to extract usernames, lists, hashtags and URLs from Tweet text.


Nested Class Summary
static class Extractor.Entity
           
 
Constructor Summary
Extractor()
          Create a new extractor.
 
Method Summary
 java.util.List<java.lang.String> extractHashtags(java.lang.String text)
          Extract #hashtag references from Tweet text.
 java.util.List<Extractor.Entity> extractHashtagsWithIndices(java.lang.String text)
          Extract #hashtag references from Tweet text.
 java.util.List<java.lang.String> extractMentionedScreennames(java.lang.String text)
          Extract @username references from Tweet text.
 java.lang.String extractReplyScreenname(java.lang.String text)
          Extract a @username reference from the beginning of Tweet text.
 java.util.List<java.lang.String> extractURLs(java.lang.String text)
          Extract URL references from Tweet text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Extractor

public Extractor()
Create a new extractor.

Method Detail

extractMentionedScreennames

public java.util.List<java.lang.String> extractMentionedScreennames(java.lang.String text)
Extract @username references from Tweet text. A mention is an occurance of @username anywhere in a Tweet.

Parameters:
text - of the tweet from which to extract usernames
Returns:
List of usernames referenced (without the leading @ sign)

extractReplyScreenname

public java.lang.String extractReplyScreenname(java.lang.String text)
Extract a @username reference from the beginning of Tweet text. A reply is an occurance of @username at the beginning of a Tweet, preceded by 0 or more spaces.

Parameters:
text - of the tweet from which to extract the replied to username
Returns:
username referenced, if any (without the leading @ sign). Returns null if this is not a reply.

extractURLs

public java.util.List<java.lang.String> extractURLs(java.lang.String text)
Extract URL references from Tweet text.

Parameters:
text - of the tweet from which to extract URLs
Returns:
List of URLs referenced.

extractHashtags

public java.util.List<java.lang.String> extractHashtags(java.lang.String text)
Extract #hashtag references from Tweet text.

Parameters:
text - of the tweet from which to extract hashtags
Returns:
List of hashtags referenced (without the leading # sign)

extractHashtagsWithIndices

public java.util.List<Extractor.Entity> extractHashtagsWithIndices(java.lang.String text)
Extract #hashtag references from Tweet text.

Parameters:
text - of the tweet from which to extract hashtags
Returns:
List of hashtags referenced (without the leading # sign)


Copyright © 2010 Twitter, Inc. All Rights Reserved.