Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created January 1, 2021 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/de3bb8976570caa72bd0296a41c60c5b to your computer and use it in GitHub Desktop.
Save amankharwal/de3bb8976570caa72bd0296a41c60c5b to your computer and use it in GitHub Desktop.
log_likelihood_jane = 0
log_likelihood_shakespeare = 0
for i in range(len(sense)-1):
current_char = sense[i].lower()
next_char = sense[i+1].lower()
if (current_char in state) & (next_char in state):
current_char_id = char2id_dict[current_char]
next_char_id = char2id_dict[next_char]
if TM_emma[current_char_id][next_char_id] != 0 and TM_caesar[current_char_id][next_char_id] != 0:
log_likelihood_jane += np.log(TM_emma[current_char_id][next_char_id])
log_likelihood_shakespeare += np.log(TM_caesar[current_char_id][next_char_id])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment