Recognizing abbreviated commands using `tries'
Roy Mongiovi
roy at prism.gatech.EDU
Wed Jan 10 17:07:00 AEST 1990
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 at prism.gatech.edu
More information about the Comp.lang.c
mailing list