Last active
September 2, 2020 19:23
-
-
Save josht-jpg/1ca8fde834ed957ec31fa6af6c7a690e to your computer and use it in GitHub Desktop.
providing_context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
keep_words = ['no', 'not'] | |
stop_words_context = [w for w in stop_words if w not in keep_words] | |
negations = ['not', 'no', 'never', 'without'] | |
def bigram(book): | |
book_context = clean(book, stop_words_context) | |
book_bigrams = pd.DataFrame(list(nltk.bigrams(book_context['word'])), | |
columns = ['word1', 'word2']) | |
return book_bigrams | |
notes_bigrams = bigram(notes) | |
crime_bigrams = bigram(crime) | |
idiot_bigrams = bigram(idiot) | |
possessed_bigrams = bigram(possessed) | |
brothers_bigrams = bigram(brothers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment