Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!rutgers!ames!jaw From: jaw@ames.UUCP Newsgroups: comp.sources.d Subject: a logolept's addition to "ispell.c" Message-ID: <224@ames.UUCP> Date: Mon, 26-Jan-87 18:54:35 EST Article-I.D.: ames.224 Posted: Mon Jan 26 18:54:35 1987 Date-Received: Tue, 27-Jan-87 05:57:31 EST Organization: NASA Ames Research Center, Moffett Field, CA Lines: 84 Keywords: word search # "i put a spell on you" -- screamin' jay hawkins though the "one-off" correction capability of 'ispell' is useful, a more general interactive lookup capability using wildcards can easily be added via an 'L' command. for example, to look up the word silhouette the mods below let one input sil*et* for quick search using my fast 'e?grep' (less than a second on the venerable 11/750). shell syntax is chosen over 'grep' syntax for ease of use by novices, as well as minimum typing. if you want to get fancy (or move up to /usr/dict/web2), consider pre-processing the grep command below with 'look' where possible, though not all systems have this. the only other things i'd want to see in future 'ispell' versions would be the user dictionary 'fix'er mentioned in this forum ('awk' is natural for this) run in conjunction with hashing the smaller local lists into the large memory table for uniform affix handling. it's odd that this is not done currently. ames!jaw ----- the diffs to file ispell.c: add to givehelp(), after ... printf ("0-9 Replace ..."); ... < printf ("L Look up words in system dictionary.\r\n"); while you're at it, practice what 'ispell' preaches by correcting the spelling error (!) < printf ("X Exit immediately. Asks for confirmation. "); --- > printf ("X Exit immediately. Asks for conformation. "); then fold in this command switch: < case 'l': case 'L': < { < char buf[100]; < move (18, 0); < printf ("Lookup string ('*' is wildcard): "); < if (getline (buf) == NULL) { < putchar (7); < erase (); < goto checkagain; < } < printf ("\r\n\r\n"); < lookharder (buf); < erase (); < goto checkagain; < } finally, append routine lookharder() to the end of ispell.c: < lookharder(string) < char *string; < { < char cmd[150]; < char *g, *s, grepstr[100]; < < g = grepstr; < for (s = string; *s != '\0'; s++) < if (*s == '*') < *g++ = '.', *g++ = '*'; < else < *g++ = *s; < *g = '\0'; < if (grepstr[0]) { < sprintf (cmd, "/usr/local/egrep -i '^%s$' /usr/dict/words", grepstr); < shellescape (cmd); < } < } be sure to use the 5-10x faster 'egrep' in the mod.sources archive. the kanji-ready, grep-unified, even swifter in cases 'e?grep' version is slated to appear in mod.sources "soon".