-
Notifications
You must be signed in to change notification settings - Fork 862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NER] add an NER visualizer #2500
Conversation
Job PR-2500-3bc908a is done. |
Job PR-2500-0ad8a2f is done. |
if entity_group.startswith("B-") or entity_group.startswith("I-"): | ||
entity_group = entity_group[2:] | ||
if entity_group not in self.colors: | ||
self.colors.update({entity_group: "#%06X" % randint(0, 0xFFFFFF)}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can potentially add a “seed” option in initializer and draw random integers from the random state: https://numpy.org/doc/stable/reference/random/legacy.html?highlight=numpy%20random%20randomstate#numpy.random.RandomState
this will ensure that the colors picked for each NERVisualizer instance will be the same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switched to randomstate and the seed is made configurable in the latest commit.
Job PR-2500-a37fcdc is done. |
------- | ||
An NER html visualizer. | ||
""" | ||
visualizer = NERVisualizer(prediction, sentence) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little curious about the advantages of defining class NERVisualizer
. Would the visualization effect be the same if we call a function with the same functionality as the above _repr_html_
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
repr_html is an interface provided by IPython for display. It can be used to display the object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a docstring to the _repr_html_
so that developers would know about this interface?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Visualization looks great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great.
Job PR-2500-f50a662 is done. |
Job PR-2500-6a77759 is done. |
Description of changes:
Users can visualize the ner predictions using the added visualize_ner function.
and it will be rendered as:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.