silpa-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[silpa-discuss] Optimization idea


From: Vasudev Kamath
Subject: [silpa-discuss] Optimization idea
Date: Sat, 24 Apr 2010 19:06:39 +0530
User-agent: KMail/1.12.4 (Linux/2.6.33-2.slh.6-sidux-686; KDE/4.3.4; i686; ; )

Hi,
In the spell checker module as per my notice first the dictionary file is read 
and converted into a set object later in the suggest function each words first 
letter is compared with current words first letter to get a rough list of 
candidates which is then fine grained to get actual candidates by applying some 
algorithms.
Here is a overview of my idea: Instead of keeping all words in dictionary for 
the language (i.e self.NWORDS[self.lang] = ) as set or list objects we can pre 
process these words to get a dictionary having keys as the first letters of 
word (basically keys are alphabets) and value for each keys as words begining 
with that alphabets. something like this
{a:[apple,agony,...],b:[banana,bomb,...] .... }
and this process of creation of dictionary is done only once for each of the 
languages and it avoids frequent comparisons to find all words with same 
starting letters each time.
I'm attaching the code please go through and let me know what you think about 
this. I may be wrong in my approach if so please correct me.

Thanks and Regards
Vasudev Kamath

Attachment: sorter.py
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]