biolab / orange3-text

🍊 :page_facing_up: Text Mining add-on for Orange3
Other
127 stars 84 forks source link

LDAvis: broken after wrong input #1001

Closed wvdvegte closed 1 year ago

wvdvegte commented 1 year ago

Describe the bug I was demonstrating Topic Modelling to a colleague. Its output was connected to LDAvis. After switching Topic Modelling from LDA to LSI, an error message (that I can no longer reproduce) came up, and LDAvis could no longer show its visualization, even after setting Topic Modelling back to LDA. I can understand that LDAvis works with LDA-based input only, but it shouldn't crash. Restarting Orange and even restarting my Mac couldn't get LDAvis back to work, and each time I open a workflow with the widget, the attached error message comes up. And if I open LDAvis and select a topic, the following message appears:

Error encountered in widget LDAvis:

Traceback (most recent call last): File "/Applications/Orange3.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/orangewidget/gui.py", line 2261, in call self.func(**kwds) File "/Applications/Orange3.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/orangecontrib/text/widgets/owldavis.py", line 316, in on_params_change adj_prob = self.compute_relevance(topic) File "/Applications/Orange3.app/Contents/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/orangecontrib/text/widgets/owldavis.py", line 297, in compute_relevance tp, mp = topic[nonzero], self.term_frequency[nonzero] IndexError: boolean index did not match indexed array along dimension 1; dimension is 1 but corresponding boolean dimension is 928

To Reproduce Steps to reproduce the behavior:

  1. Connect Topic Modelling to a Corpus output
  2. Select Latent Dirichlet Allocation
  3. Connect LDAvis to its output
  4. Select latent Semantic Indexing in Topic Modelling (or perhaps one of the other options)

Expected behavior No crash - perhaps the input connector to LDAvis should become a dashed one

Orange version: 3.35.0

Text add-on version: 1.14.0

Operating system: Mac OS Ventura 13.5 on Silicon

Exception.txt

PrimozGodec commented 1 year ago

Thank you for reporting. I can reproduce the error after selecting LSI and then back to LDA.

PrimozGodec commented 1 year ago

In #1008, I propose a fix. Hopefully, it fixes the error completely (at least, it fixes it in my case).

Setting a connection to dashed lines is technically impossible, so we keep an error in a widget that warns that data are unsuitable.