Skip to content

About

A quick example demonstrating an efficient autocomplete algorithm matching against a list of words in python.

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Autocompletion with Python

A simple autocompletion class that performs an efficient lookup for words that match a prefix. The subsequent list is return sorted and with any duplicates removed.

Features

The prefix "tra" would return a list like: ["trace", "track", "trade", etc].

The file autocomplete.py is a standalone script that can be executed directly. The script requires the specification of a text file that contains the dictionary of words (one word per line). On most unix systems /usr/share/dict/words is a good test case.

Example

$> /usr/bin/python2.7 autocomplete.py /usr/share/dict/words
Please type the prefix of a word: 
elep
Suggestions:
elephant
elephanta
elephantiac
elephantiasic
elephantiasis
elephantic
elephanticide
elephantine
elephantlike
elephantoid
elephantoidal
elephantous
elephantry

Dependencies

The class has no external dependencies other than python. The code has been tested under python 2.7 and 3.3.

About

A quick example demonstrating an efficient autocomplete algorithm matching against a list of words in python.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages