Skip to content

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

License

Unlicense, Unknown licenses found

Licenses found

Unlicense
LICENSE
Unknown
LICENSE.md
Notifications You must be signed in to change notification settings

danbruce/python_autocomplete

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

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

License

Unlicense, Unknown licenses found

Licenses found

Unlicense
LICENSE
Unknown
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages