NorskRegnesentral / skweak

skweak: A software toolkit for weak supervision applied to NLP tasks
MIT License
918 stars 73 forks source link

skweak.utils.display_entities behavior in Jupyter notebooks #5

Closed wpnbos closed 3 years ago

wpnbos commented 3 years ago

Windows 10 Python 3.8.3

Hi,

It would seem that the skweak.utils.display_entities() function with the "hmm" parameter has some undesired behavior in Jupyter notebooks. Rather than displaying the entities like it would with the "spacy" parameter, which looks like this:

Screenshot 2021-04-29 113309

Where lines are printed to fit the screen, and entities are in a box with their label, the "hmm" parameter gives this result:

Screenshot 2021-04-29 113328

With lines being displayed awkwardly, and entity labels masking the actual word that was tagged (the COMPANY tag shows, but the entity "Reuters" is not visible).

These pictures are taken from a top-to-bottom run, unaltered quick_start.ipynb as found in the examples directory.

Love the package by the way!

plison commented 3 years ago

Yes you're perfectly right, I had only tested this behaviour in Jupyter Lab, but not older Jupyter Notebooks. We had implemented a functionality that relies on HTML tooltips to interactively visualise the prediction of each labelling function for a given token. But it turns out HTML tooltips are only supported in Jupyter Lab.

So I've turned the use of tooltips off by default. But if you wish to display those tooltips, I'd recommend to switch to Jupyter Lab (which, in my opinion, is a big improvement compared to Jupyter Notebook), and set the flag add_tooltip=True.