Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created Jan 1, 2021
Embed
What would you like to do?
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