Skip to content

Ontology: adding empty words crashes #883

@ajdapretnar

Description

@ajdapretnar

Describe the bug
Ontology crashes with:

---------------------------- IndexError Exception -----------------------------
Traceback (most recent call last):
  File "/Users/ajda/orange/orange3-text/orangecontrib/text/widgets/owontology.py", line 795, in __on_ontology_data_changed
    self.__update_score()
  File "/Users/ajda/orange/orange3-text/orangecontrib/text/widgets/owontology.py", line 853, in __update_score
    score = round(self.__onto_handler.score(tree), 2) \
  File "/Users/ajda/orange/orange3-text/orangecontrib/text/ontology.py", line 342, in score
    self._get_embeddings(tree.labels, wrap_callback(callback, end=0.7)),
  File "/Users/ajda/orange/orange3-text/orangecontrib/text/ontology.py", line 366, in _get_embeddings
    embs = self.embedder(missing, callback=wrap_callback(callback, start=0.6, end=0.9))
  File "/Users/ajda/orange/orange3-text/orangecontrib/text/vectorization/sbert.py", line 50, in __call__
    sorted_texts = sorted(
  File "/Users/ajda/orange/orange3-text/orangecontrib/text/vectorization/sbert.py", line 52, in <lambda>
    key=lambda x: len(x[1][0]) if x[1] is not None else 0,
IndexError: string index out of range
-------------------------------------------------------------------------------

To Reproduce
Steps to reproduce the behavior:

  1. Open Ontology.
  2. Click + a couple of times.

Expected behavior
No crash.

Orange version:
3.32.0

Text add-on version:
1.7.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions