MaartenGr / MaartenGr/BERTopic
find_topics(topic) crashes if topic is a 1-element list
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.8k
- Forks
- 920
- Avg merge
- 22h 24m
- Merged PRs (30d)
- 5
Description
### Have you searched existing issues? 🔎
- [x] 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
```python
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the provided BERTopic reproduction with find_topics(["internet"], top_n=50), then inspect the find_topics entry point and its handling of single-item lists. Done means the one-element-list call completes consistently with the string and multi-item-list forms, with regression coverage for the reported case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, scikit-learn
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100