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: Plants For A Future <webmaster@pfaf.org>
  • To: Permaculture Plant Database <pcplantdb@lists.ibiblio.org>
  • Subject: Re: [pcplantdb] Eden 0.1.3 release - testing search again
  • Date: Sun, 26 Dec 2004 21:19:46 +0000 (GMT)

On Fri, 24 Dec 2004, Chad Knepp wrote:

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.

Cool, it is a neet way of doing it. There are efficiency questions
as there can be a lot of substrings to test for. I've had a play with
this sort of stuff in the past and there are different ways to implement
such a scheme some are more efficient way to do it. Can't remember off
top of my head which way to order the loops but there are ways which
prevent most of tests. Do we have any way of testing time for these
sorts of things. If spped turns out to be a problem then this bit can be
tuned a lot. Might even consider implementing in C for max efficiency.

--
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

yes this is neet, whats the typical length of a substring?

I've got a lot of log file data which records all the searches which
people have done. I could pass some of this on if you want some data to
test on.

Rich
--




Archive powered by MHonArc 2.6.24.

Top of Page