@verbose
def corpusreader_demo():
 from nltk.corpus import twitter_samples as tweets
 print()
 print('Complete tweet documents')
 print(SPACER)
 for tweet in tweets.docs('tweets.20150430-223406.json')[:1]:
  print(json.dumps(tweet, indent=1, sort_keys=True))
 print()
 print('Raw tweet strings:')
 print(SPACER)
 for text in tweets.strings('tweets.20150430-223406.json')[:15]:
  print(text)
 print()
 print('Tokenized tweet strings:')
 print(SPACER)
 for toks in tweets.tokenized('tweets.20150430-223406.json')[:15]:
  print(toks)

@ verbose def corpusreader_demo ( ) : from nltk . corpus import twitter_samples as tweets print ( ) print ( 'Complete tweet documents' ) print ( SPACER ) for tweet in tweets . docs ( 'tweets.20150430-223406.json' ) [ : 1 ] : print ( json . dumps ( tweet , indent = 1 , sort_keys = True ) ) print ( ) print ( 'Raw tweet strings:' ) print ( SPACER ) for text in tweets . strings ( 'tweets.20150430-223406.json' ) [ : 15 ] : print ( text ) print ( ) print ( 'Tokenized tweet strings:' ) print ( SPACER ) for toks in tweets . tokenized ( 'tweets.20150430-223406.json' ) [ : 15 ] : print ( toks )
use :module:twittercorpusreader tp read a file of tweets .