-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
displacy span rendering enhancement #3850
Comments
Thanks for raising this – it's definitely something I've thought about before! I wonder if we could maybe just add an option to replace the templates used for the page, container and spans. That would allow full customisation, without the awkwardness of just inserting HTML fragments into the templates (and the error potential here). Another, slightly more complex solution would be to change the rendering slightly and use templating functions instead of just template strings. So there would be a function along the lines of |
That's a great idea. Maybe the solution is to combine the two? Have a function (e.g. get_entity_span_html) that gets the text, label and an html template, where this template can be a prepared template (like the one that exists now) or a completely new one, which will provide the user complete freedom. |
Ah yeah, sorry if this was confusing in my description. The idea here would be that you could override those getter functions with your own. Your function would need to take the same arguments and has to return a string of markup – everything else is up to you. |
I'm starting to work on this. Do you think it make sense to have a customizable html template for each one of the templates in the templates.py file? |
@yanaiela I think it would be good if the individual HTML templates (at least the most important ones) could be overwritten via an argument on initialization. So |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Feature description
Adding a customized html display option into the
render
functionHi!
I have a usecase where I want to add a hover into the EntityRenderer spans in displacy.
For the meantime, I just copied the code and hard-coded into it the component I needed but I thought this might be useful for other people as well, and with other customized html options.
Therefore, I'll present here the implementation idea on changing the code before a PR, and I'd be happy to get a feedback if you think this would be a useful feature / how to make it more generic.
So the idea is to add into the
options
argument another dictionary parameter. This dictionary would consist of additional html code that would be inserted into the html place-holders. The keys of the additional dictionary are additional html code and their values are elements that can be inserted into the keys, is necessary. When that dictionary is not empty, the html place-holders -TPL_ENT
andTPL_ENT_RTL
would add these additional components.How does this sound?
Also, I'm not sure if this is useful for the
DependencyRenderer
, let me know if you think it is.The text was updated successfully, but these errors were encountered: