nltk.twitter.TweetViewer

class nltk.twitter.TweetViewer[source]

Bases: TweetHandlerI

Handle data by sending it to the terminal.

handle(data)[source]

Direct data to sys.stdout

Returns

return False if processing should cease, otherwise return True.

Return type

bool

Parameters

data – Tweet object returned by Twitter API

on_finish()[source]

Actions when the tweet limit has been reached

__init__(limit=20, upper_date_limit=None, lower_date_limit=None)[source]
Parameters
  • limit (int) – The number of data items to process in the current round of processing.

  • upper_date_limit (tuple) – 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. date_limit=(2015, 4, 1, 12, 40) for 12:30 pm on April 1 2015.

  • lower_date_limit (tuple) – The date at which to stop collecting new data. See upper_data_limit for formatting.

check_date_limit(data, verbose=False)[source]

Validate date limits.

do_continue()[source]

Returns False if the client should stop fetching Tweets.

counter

A flag to indicate to the client whether to stop fetching data given some condition (e.g., reaching a date limit).

do_stop

Stores the id of the last fetched Tweet to handle pagination.