Skip to content

find_topics(topic) crashes if topic is a 1-element list #2475

@raffaelemancuso

Description

@raffaelemancuso

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Desribe the bug

topic_model.find_topics(topic) crashes if topic is a list with 1 string only.

It works if topic is a string or a list of strings with len>1

Reproduction

from bertopic import BERTopic
from sklearn.datasets import fetch_20newsgroups
 
docs = fetch_20newsgroups(subset='all',  remove=('headers', 'footers', 'quotes'))['data']

topic_model = BERTopic()
topics, probs = topic_model.fit_transform(docs)
similar_topics, similarities = topic_model.find_topics(["internet"], top_n=50)

BERTopic Version

0.17.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions