case studyclassifying reddit posts listing first data preparation function and execution we'll use data['all_words'for data exploration create pointer to awlite data row[ is def data_processing(sql)titlerow[ execute(sqlfetch data is topic textdata {'wordmatrix':[],'all_words':[]row by row we turn them row fetchone(into single while row is not nonetext blob wordrow nltk tokenize word_tokenize(row[ ]+"+row[ ]wordrow_lowercased lowercasearray(wordrowwordrow_nostopwords wordfilter(stopwords,wordrow_lowercaseddata['all_words'extend(wordrow_nostopwordsdata['wordmatrix'append(wordrow_nostopwordsrow fetchone(get new document return data from sqlite database subreddits ['datascience','gameofthrones'data {for subject in subredditsdata[subjectdata_processing(sql='''select topictitle,topictext,topiccategory from topics where topiccategory '''+"'"+subject+"'"data['wordmatrix'is matrix comprised of word vectors vector per document our subreddits as defined earlier call data processing function for every subreddit our data_processing(function takes in sql statement and returns the documentterm matrix it does this by looping through the data one entry (reddit topicat time and combines the topic title and topic body text into single word vector with the use of word tokenization tokenizer is text handling script that cuts the text into pieces you have many different ways to tokenize textyou can divide it into sentences or wordsyou can split by space and punctuationsor you can take other characters into accountand so on here we opted for the standard nltk word tokenizer this word tokenizer is simpleall it does is split the text into terms if there' space between the words we then lowercase the vector and filter out the stop words note how the order is important herea stop word in the beginning of sentence wouldn' be filtered if we first filter the stop words before lowercasing for instance in " like game of thrones,the "iwould not be lowercased and thus would not be filtered out we then create word matrix (term-document matrixand list containing all the words notice how we extend the list without filtering for doublesthis way we can create histogram on word occurrences during data exploration let' execute the function for our two topic categories figure shows the first word vector of the "datasciencecategory print data['datascience']['wordmatrix'][