Skip to content

Instantly share code, notes, and snippets.

@hanneshapke
Last active April 16, 2018 02:46
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 hanneshapke/6a8609c738cb913c846e40d0df777293 to your computer and use it in GitHub Desktop.
Save hanneshapke/6a8609c738cb913c846e40d0df777293 to your computer and use it in GitHub Desktop.
get_highlighted_tokens
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