Re: searching algorithm

2007-05-17 Thread Neil Cerutti
d use a list in order to build the > structure in pieces, one for each letter, and then add them in. > > At the top level, the letters do not need explicit storage. > The first subtree is for words starting with 'a', etc. In > other words, the position of each subtree indic

Re: searching algorithm

2007-05-12 Thread aaronwmail-usenet
On May 10, 1:26 pm, Gigs_ <[EMAIL PROTECTED]> wrote: > Hi all! > > I have text file (english-croatian dictionary) with words in it in > alphabetical > order. > This file contains 17 words in this format: > english word: croatian word Let's assume it's okay to have all the data in memory. In m

Re: searching algorithm

2007-05-11 Thread Michael Bentley
On May 11, 2007, at 3:50 AM, Michael Bentley wrote: > > Here's an idea: use a rats' nest of dictionaries and do all the > lookup work up front when you build the rats' nest. Maybe something > like this: ... Oops! This is better :-) #! /usr/bin/env python import pprint dictionary = """absinth

Re: searching algorithm

2007-05-11 Thread Alex Martelli
Michael Bentley <[EMAIL PROTECTED]> wrote: > > > > Call me dense, but how does one do this in Python - which doesn't have > > pointers? Dictionaries with dictionaries within dictionaries... (with > > each letter as the key and the its children as values) is going to be > > extremely space ineffici

Re: searching algorithm

2007-05-11 Thread Neil Cerutti
On 2007-05-11, ciju <[EMAIL PROTECTED]> wrote: > By the way, both data structures could be implemented as tuple > in python, for I suppose, if only lookup is needed tuple gives > better performance than list. I used a list instead of a tuple where I thought a list would be convenient while buildin

Re: searching algorithm

2007-05-11 Thread Michael Bentley
On May 10, 2007, at 12:26 PM, Gigs_ wrote: > Hi all! > > I have text file (english-croatian dictionary) with words in it in > alphabetical > order. > This file contains 17 words in this format: > english word: croatian word > > I want to make instant search for my gui > Instant search, i me

Re: searching algorithm

2007-05-11 Thread Michael Bentley
> > Call me dense, but how does one do this in Python - which doesn't have > pointers? Dictionaries with dictionaries within dictionaries... (with > each letter as the key and the its children as values) is going to be > extremely space inefficient, right? Isn't *everything* in python essentially

Re: searching algorithm

2007-05-10 Thread ciju
On May 11, 3:12 am, Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-05-10, Gordon Airporte <[EMAIL PROTECTED]> wrote: > > > > > > >> For the above (abrideged) dictionary, you would generate (use a > >> fixed-width "programmers" font so the tree looks good): > > >> a > >>

Re: searching algorithm

2007-05-10 Thread Terry Reedy
"Neil Cerutti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Every node is a tuple of its letter, a list of its children, and | a list of its words. So the two 'pelin' nodes would be (with 'e' | referenced in the 'h' node): | | ('h', [('e', [], ['pelin'])], ['pelin']) | | That wou

Re: searching algorithm

2007-05-10 Thread Neil Cerutti
On 2007-05-10, Gordon Airporte <[EMAIL PROTECTED]> wrote: > >> For the above (abrideged) dictionary, you would generate (use a >> fixed-width "programmers" font so the tree looks good): >> >> a >> | >> b >> | >> s

Re: searching algorithm

2007-05-10 Thread James Stroud
Gordon Airporte wrote: > >> For the above (abrideged) dictionary, you would generate (use a >> fixed-width "programmers" font so the tree looks good): >> >> a >> | >> b >> | >> s >> / \ >>

Re: searching algorithm

2007-05-10 Thread Gordon Airporte
> For the above (abrideged) dictionary, you would generate (use a > fixed-width "programmers" font so the tree looks good): > > a > | > b > | > s > / \ >i o > / /

Re: searching algorithm

2007-05-10 Thread Terry Reedy
"Neil Cerutti" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | On 2007-05-10, Gigs_ <[EMAIL PROTECTED]> wrote: | > if user type: "abs" program should list all words above in | > english and in croatian if user type: "absorb" than program | > should list last 3 words in english and i

Re: searching algorithm

2007-05-10 Thread Neil Cerutti
On 2007-05-10, Gigs_ <[EMAIL PROTECTED]> wrote: > Hi all! > > I have text file (english-croatian dictionary) with words in it > in alphabetical order. This file contains 17 words in this > format: english word: croatian word > > I want to make instant search for my gui Instant search, i mean >

Re: searching algorithm

2007-05-10 Thread Sébastien Ramage
I have made a script that search anagram based on the ODS file ( call OSW in english, Official Scrabble Words) it load a file that contain 369085 words (one word per line) I create a dictionnary and store word into using the length of the word as key example : mydict[2] contain a list of word with

searching algorithm

2007-05-10 Thread Gigs_
Hi all! I have text file (english-croatian dictionary) with words in it in alphabetical order. This file contains 17 words in this format: english word: croatian word I want to make instant search for my gui Instant search, i mean that my program search words and show words to user as user