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
Deprecate GhostScript dependency in favor of svgling
#2875
Comments
Great idea! |
sounds good to me too! |
Thanks for proposing this @tomaarsen, I'd be happy for this to happen for my own selfish reasons. No doubt this dependency would stress test
|
I like the sound of all that @rawlins. Perhaps we can take advantage of your experience to best guide an implementation. Here are some ideas I had, and I'd like to get some feedback on them: Idea 1:Simply import
I would rather define a Idea 2:A second idea is to simply remove def _repr_svg_(self):
from svgling import draw_tree
return draw_tree(self)._repr_svg_() This is the simplest implementation I could see working well. It tackles all 3 issues I had with idea 1. Idea 3:Beyond that, there are some iterations possible on idea 2: def _repr_svg_(self):
from svgling.core import TreeLayout
return TreeLayout(self)._repr_svg_() def _repr_svg_(self):
from svgling.core import TreeLayout, TreeOptions
return TreeLayout(self, options=TreeOptions())._repr_svg_() def _repr_svg_(self):
from svgling.core import TreeLayout, nltk_tree_options
return TreeLayout(self, options=nltk_tree_options)._repr_svg_() Although possible, I don't feel like passing along this options value adds much, as users can't really modify it regardless. Beyond these ideas, there might be other implementations that work better in conjunction with svgling. I'm definitely open to suggestions and discussion. Beyond that, I would be interested in supporting the ability to use the original tool instead. There's a few options:
I fear that option 1 will be extraordinarily hacky, and that option 2 would completely unnecessarily add a new method. I'm not sure if there is a simple and intuitive way to support multiple plotting methods. So I'm leaning towards option 3. After all, trees already support the I'm open to discussion on this.
|
Totally agree that idea 1 is non-ideal, I would actually prefer to eventually remove the side-effect monkeypatching code from I don't know that I have strong preferences between your options 2-3; I think the main question (for you basically) is whether there is a need for passing rendering options somehow when looking at nltk.Tree objects in jupyter, or whether it's enough to just instruct users to call Re adjusting the png code, one thing to keep in mind is that jupyter attempts to call all reprs regardless of which it displays. I might recommend keeping it as a Then, if users have everything installed and don't want the default they could choose a preferred |
@tomaarsen I favour the simplest possible solution, since that is also what is easiest to maintain in the long term. Complexities should "pay their way", ie justify the additional effort. NB people have access to the source code for old versions of NLTK if they want legacy functionality. |
Eventually, you might be able to use
I'd rather not rely on And as @stevenbird mentioned, it's likely best to keep this simple, and just remove the old outdated |
Interesting question, I'll look into this, I haven't paid much attention to the extra |
* Resolved un-pickling issue with ParentedTrees for Python 3.7+ * Split tree.py up into its own module * Fixed improper import from tree/probabilistic.py * Import tree in the list of packages, instead of modules * The label for a node doesn't need to be a str, it can be Any * Renamed ltk.tree.parse to ltk.tree.parsing to avoid accidental overwrites * Moved TreePrettyPrinter to tree package The old import still works, but throws a warning. Perfect! * Improved import issue with prettyprinter * Moved treetransforms functions to tree package * Heavily shrunk treetransforms.py * Prevent shallow copy on ParentedTree - added doctest w. documentation * Deprecate GhostScript in favor of svling See #2875
Hello!
This is following up from discussion from #1887. I would like to suggest to deprecate the dependency on GhostScript from Tree's
_repr_png_
:nltk/nltk/tree.py
Lines 812 to 823 in f12df18
We could start supporting SVG's rather than simply PNG's, by moving to using
svgling
. This module has been written with NLTK support in mind, so I presume that using it won't be too much of a hastle.It would move the dependency from some downloaded third party tool which requires
subprocess
, temporarily files, etc. to a purely Python module.Beyond how this third party tool is executed, the output also slightly differs, as is expected.
This is the current output in any jupyter notebook:
This is the output when simply importing
svgling
:I would also like to invite the author of
svgling
, @rawlins, for their opinion on fully deprecatinggs
in favour of their module. Are there any issues that we should be aware of?What's everyone's thoughts on this?
The text was updated successfully, but these errors were encountered: