2023-08-12    Share on: Twitter | Facebook | HackerNews | Reddit

Split glued or joined words

wordninja package

github stars shield

install wordninja package: pip install wordnija

>>> import wordninja
>>> wordninja.split('bettergood')
['better', 'good']

wordsegment package

github stars shield

install the wordsegment package: pip install wordsegment.

use programatically:

>>> from wordsegment import load, segment
>>> load()
>>> segment('thisisatest')
['this', 'is', 'a', 'test']

or from CLI

$ echo thisisatest | python -m wordsegment
this is a test

Solutions from: string - How can I split multiple joined words? - Stack Overflow