/*

    File:          tell.c
    Author:        Graham Toal
    Purpose:       offer correct spelling
    Creation date: 22/06/90
    Lastedit:      22:24:32

    Description:

       Like the unix 'spelltell' command.

*/


/* Manadatory header files */
#include <stdio.h>
#include "dawg.h"
#include "grope.h"
#include "utils.c"

/* Headers here as needed on per-program basis */
#include <ctype.h>  /* eg, for isalpha() */

/* Spelling library utilities */
#include "init.c"      /* Loading dicts */
#include "dyntrie.c"   /* Creating dicts at run-time */
#include "print.c"     /* Printing dicts */
#include "check.c"     /* Checking words */
#include "locate.c"    /* Finding words by their stems */

#include "soundex.c"   /* Soundex algorithm for word-likeness comparison */
#include "similcmp.c"  /* Closeness-metric for correction */
#include "correct.c"   /* Hack code to attempt error correction (uses above) */

/* Let's be friendly to these guys... */
#ifdef SYS_MAC
/* To compile with THINK C 4.0, place all the relevant .h and .c
   files in a folder.  Then create a project which contains this main.c
   and the libraries unix and ANSI.
*/
#include <unix.h>
#include <stdlib.h>
#include <console.h>
#endif

/* Your own header files go here, for instance:
               #include "readword.h"
 */



int
#ifdef PROTOTYPES
main(int argc, char **argv)
#else
main(argc, argv)
int argc;
char **argv;
#endif
{
NODE PCCRAP *dawg;
INDEX edges;
int each;

#ifdef SYS_MAC
  argc = ccommand(&argv);  /* Mac users have my sympathy */
#endif

  /* Your program goes here... */
  if (argc == 1) {
    fprintf(stderr, "usage: %s mispeled wurdz\n", argv[0]);
    exit(EXIT_ERROR);
  }
  if (!dawg_init("", &dawg, &edges)) exit(EXIT_ERROR);
  for (each = 1; each < argc; each++) {
    fprintf(stderr, "* %s:\n", argv[each]);
    if (!dawg_correct(dawg, argv[each])) {
      fprintf(stderr, "(none found)\n");
    }
    if (each+1 != argc) fprintf(stderr, "\n");
  }

  exit(EXIT_OK);
}
