user18853421
user18853421

Reputation:

A way to separate one word into two separate words using NLTK?

If we have an unseparated word, let's say doctorsofamerica Is there an NLTK import that I can use to separate this into

doctors of america

Thanks!

Upvotes: 0

Views: 320

Answers (1)

idanz
idanz

Reputation: 877

If anything other than NLTK is an option, I used to work with Word Segmentation which gave pretty good results for simple cases. Regarding your use case, it would look like this:

from wordsegment import load, segment

load()
separated = segment('doctorsofamerica')
print(' '.join(separated))

Output:

doctors of america

Upvotes: 1

Related Questions