Skip to Content.
Sympa Menu

pcplantdb - Re: [pcplantdb] Eden 0.1.3 release - testing search again

pcplantdb@lists.ibiblio.org

Subject: pcplantdb

List archive

Chronological Thread  
  • From: Chad Knepp <pyg@galatea.org>
  • To: Permaculture Plant Database <pcplantdb@lists.ibiblio.org>
  • Subject: Re: [pcplantdb] Eden 0.1.3 release - testing search again
  • Date: Fri, 24 Dec 2004 07:34:32 -0600

Richard Morris writes:
> Lawrence F. London, Jr. wrote:
> > Chad Knepp wrote:
> >
> >> Well, I can think of a couple of reasons. Elaeagnus has an 'a' in it
> >> that I forget a lot myself. Eden does accommodate 'alternative'
> >
> Spelling of latin names is a big issue.
> The way I've handled this is to put every concievable spelling as a
> synonym.

Interesting. I've handled it very differently. Eden separates words
into substrings and looks for names that are 'like %substring%'. If
you spell the word correctly every substring matches. If you butcher
it, hopefully some of the substrings will match. I've found this to be
both very simple and very effective solution. One of the performance
enhancing changes I made recently was decreasing the number of
substrings a word is seperated into. Perhaps I've changed it too far
the other way.

Just for fun, I'm appending the substring method from Eden/Search.py.
I think it's a neat bit of code.

--
Chad Knepp
python -c 'import base64;print base64.decodestring("cHlnQGdhbGF0ZWEub3Jn")'


def subStrings(word, substrings, min_len = 3):
"""
Suppa duppa substring smashing action! Hi-Yaaaaa....

Divides 'word' into 'substrings' number of sub strings that
have a minimum number of characters of 'min_length'

Returns list of sub strings
"""

strings = []

increment = len(word) / substrings
extra_chars = len(word) % substrings

if increment < min_len:
increment = min_len
extra_chars = len(word) % min_len
substrings = len(word) / min_len

for chunk in range(substrings):
if extra_chars:
strings.append(word[:increment+1])
word = word[increment+1:]
extra_chars -= 1
else:
strings.append(word[:increment])
word = word[increment:]

return strings





Archive powered by MHonArc 2.6.24.

Top of Page