class documentation
class TweetWriter(TweetHandlerI): (source)
Constructor: TweetWriter(limit, upper_date_limit, lower_date_limit, fprefix, ...)
Handle data by writing it to a file.
Method | __init__ |
The difference between the upper and lower date limits depends on whether Tweets are coming in an ascending date order (i.e. when streaming) or descending date order (i.e. when searching past Tweets). |
Method | do |
Returns False if the client should stop fetching Tweets. |
Method | handle |
Write Twitter data as line-delimited JSON into one or more files. |
Method | on |
Actions when the tweet limit has been reached |
Method | timestamped |
No summary |
Instance Variable | counter |
A flag to indicate to the client whether to stop fetching data given some condition (e.g., reaching a date limit). |
Instance Variable | fname |
Undocumented |
Instance Variable | fprefix |
Undocumented |
Instance Variable | gzip |
Undocumented |
Instance Variable | output |
Undocumented |
Instance Variable | repeat |
Undocumented |
Instance Variable | startingup |
Undocumented |
Instance Variable | subdir |
Undocumented |
Method | _restart |
Undocumented |
Inherited from TweetHandlerI
:
Method | check |
Validate date limits. |
Instance Variable | do |
Stores the id of the last fetched Tweet to handle pagination. |
Instance Variable | lower |
Undocumented |
Instance Variable | upper |
Undocumented |
Inherited from BasicTweetHandler
(via TweetHandlerI
):
Instance Variable | limit |
Undocumented |
Instance Variable | max |
Undocumented |
def __init__(self, limit=2000, upper_date_limit=None, lower_date_limit=None, fprefix='tweets', subdir='twitter-files', repeat=False, gzip_compress=False):
(source)
¶
overrides
nltk.twitter.api.TweetHandlerI.__init__
The difference between the upper and lower date limits depends on whether Tweets are coming in an ascending date order (i.e. when streaming) or descending date order (i.e. when searching past Tweets).
Parameters | |
limit | Undocumented |
upper | Undocumented |
lower | Undocumented |
fprefix | Undocumented |
subdir | Undocumented |
repeat | Undocumented |
gzip | if True , ouput files are compressed with gzip. |
int limit | number of data items to process in the current round of processing. |
tuple upper | The date at which to stop collecting new data. This should be entered as a tuple which can serve as the argument to datetime.datetime . E.g. upper_date_limit=(2015, 4, 1, 12, 40) for 12:30 pm on April 1 2015. |
tuple lower | The date at which to stop collecting new data. See upper_data_limit for formatting. |
str fprefix | The prefix to use in creating file names for Tweet collections. |
str subdir | The name of the directory where Tweet collection files should be stored. |
bool repeat | flag to determine whether multiple files should be written. If True , the length of each file will be set by the value of limit . See also handle . |
overrides
nltk.twitter.api.TweetHandlerI.handle
Write Twitter data as line-delimited JSON into one or more files.
Parameters | |
data | tweet object returned by Twitter API |
Returns | |
return False if processing should cease, otherwise return True . |