Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!mips!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!uflorida!mephisto!prism!roy From: roy@prism.gatech.EDU (Roy Mongiovi) Newsgroups: comp.lang.c Subject: Re: Recognizing abbreviated commands using `tries' Message-ID: <4728@hydra.gatech.EDU> Date: 10 Jan 90 06:07:00 GMT References: <25AA6CD3.16540@paris.ics.uci.edu> Distribution: comp Organization: Georgia Institute of Technology Lines: 20 This doesn't use tries, but I did approximately the same thing in a text editor I wrote many years ago. I kept a sorted table of all the keywords I wanted to recognize. To search the table, I did a binary search basically using "strncmp(keyword, table[i], strlen(keyword))". If I didn't find a match, I knew the keyword wasn't in the table. Otherwise I probed linearly backwards and forwards in the table looking for other matches. If there weren't any the keyword is a unique abbreviation, otherwise it's ambiguous. I also augmented this to look for an exact match (strlen(keyword) == strlen(table[i])) which allowed me to enter very short (i.e. single character) entries in the table as a shorthand for certain frequently used commands. It worked really well, it was relatively fast, and it's simple. What more can you ask for? -- Roy J. Mongiovi Systems Support Specialist Office of Computing Services Georgia Institute of Technology Atlanta, Georgia 30332-0275 (404) 894-4660 uucp: ...!{allegra,amd,hplabs,ut-ngp}!gatech!prism!roy ARPA: roy@prism.gatech.edu