Last active
April 16, 2018 02:46
-
-
Save hanneshapke/6a8609c738cb913c846e40d0df777293 to your computer and use it in GitHub Desktop.
get_highlighted_tokens
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
def get_highlighted_tokens(tokens, matrix, model, layer_name, threshold, y_labels): | |
indices = get_token_indices(model, layer_name, threshold, matrix, y_labels) | |
ctokens = [] | |
for i, t in enumerate(tokens): | |
if i in indices.keys(): | |
_color = color(indices[i], threshold=threshold) | |
ctokens.append(cstr(t, color=_color)) | |
else: | |
ctokens.append(t) | |
return html_print(cstr(' '.join(ctokens), color='black') ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment