The soundex Module

(Optional, Only 1.5.2) The soundex module implements a simple hash algorithm, which converts words to 6-character strings based on their English pronunciation.

As of Version 2.0, this module is no longer included.

get_soundex(word) returns the soundex string for the given word. Words that sound similar should give the same soundex string. sound_similar(word1, word2) returns true if the two words have the same soundex. Example 14-24 uses both functions.

Example 14-24. Using the soundex Module
File: soundex-example-1.py

import soundex

a = "fredrik"
b = "friedrich"

print soundex.get_soundex(a), soundex.get_soundex(b)

print soundex.sound_similar(a, b)

F63620 F63620
1

Core Modules

More Standard Modules

Threads and Processes

Data Representation

File Formats

Mail and News Message Processing

Network Protocols

Internationalization

Multimedia Modules

Data Storage

Tools and Utilities

Platform-Specific Modules

Implementation Support Modules

Other Modules



Python Standard Library
Python Standard Library (Nutshell Handbooks) with
ISBN: 0596000960
EAN: 2147483647
Year: 2000
Pages: 252
Authors: Fredrik Lundh

Flylib.com © 2008-2020.
If you may any questions please contact us: flylib@qtcs.net