Search code examples
pythonperformancenltkwordnetlexical

Does anyone know a fast way to retrieve all 9 letter English words? - Lexical Database Searching (wordnet, python)


I am trying to sift through a lexical database (ideally wordnet via NLTK in Python) and extract all 9 letter words. Does anyone know how to do this? The documentation did not show any promising avenues.

I can't just try every 9 letter combination and check if it is defined as this will take forever. However, simply iterating through the lexical database and extracting 9 letter words is feasible.

If I could sort the database in advance, I know this could be very fast.

So this all seems possible and crossword solvers and dictionary programs must have a way of doing this. Does anyone know how to approach this in Python?


Solution

  • As you are using a database, I suppose you are using SQL to look in. If so, this request returns you every word with 9 letters in alphabetical order:

    SELECT word
    FROM dictionary
    WHERE LENGTH(word) = 9
    ORDER BY word ASC;
    

    Assuming dictionary is the name of the table and word is the name of the column.