Runtime complexity

We now have the ability to find the correct spellings of words or mark them as similar. While processing a large corpus, we can extract all unique words and compare each token against every other token.

It would take O(n2), where n is the number of unique tokens in a corpus. This might make the process too slow for a large corpus.

The alternative is to use a standard dictionary and expand the same for your corpus. If the dictionary has m unique words, this process now will be O(mn). Assuming that m<<n*m<<n2, this will be much faster than the previous approach.

Get Natural Language Processing with Python Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.