Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ritvikmath/621188d6de32cc7d3d937f22a631f7a5 to your computer and use it in GitHub Desktop.

Select an option

Save ritvikmath/621188d6de32cc7d3d937f22a631f7a5 to your computer and use it in GitHub Desktop.
#get the speech which we will try to identify
secret_speech = open('obama_speech_testing.txt', 'r').read()
secret_speech = secret_speech.replace('\n','').replace(' ',' ').lower()
list_of_phrases_secret = secret_speech.split(' ')
#get zipped group of every 3 consecutive words
secret_tups = [str(item) for item in zip(list_of_phrases_secret[:-2], list_of_phrases_secret[1:-1], list_of_phrases_secret[2:])]
#get TF dictionary for the secret speech
d_secret = get_phrase_freq_dict(secret_tups)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment