/***********************************************************************\

    Filename: correct.h

\***********************************************************************/

#ifndef SC_CORRDEF
#define SC_CORRDEF

#ifndef _PROXLIB
#include <proxlib.h>
#endif

#ifndef SC_SCDEF
#include "scdef.h"
#endif

#ifndef SC_SCPARAM
#include "scparam.h"
#endif

/* Correction pruning and control parameters. */

#define E_THRESH        0xA400  /* theta low threshold for ranking: 0.64 */
#define E_LOPLEX        2       /* low  tolerance - complexity */
#define E_HIPLEX        2       /* high tolerance - complexity */
#define E_LONVPLEX      1       /* low  tolerance - nonvowel complexity */
#define E_HINVPLEX      1       /* high tolerance - nonvowel complexity */
#define E_LOLEN         6       /* low  tolerance - full length */
#define E_HILEN         6       /* high tolerance - full length */
#define E_LOPELEN       6       /* low  tolerance - pe length */
#define E_HIPELEN       6       /* high tolerance - pe length */
#define E_SHORT         6       /* short word crossover point */

/* one alternative to a query passed to Correct */

typedef struct {
    unsigned al_simil;      /* theta-similarity to query */
    UCHAR   al_flags;       /* flags of word's reduced form */
    UCHAR   al_word[MAXWORD]; /* the decompressed alternative */
} ALTINFO;

/* This structure contains things used solely by correct. */

typedef struct CORRECT {
    /* This field must be first, as theta assumes that it is. */

    UCHAR   *co_param;      /* theta() parameters table */

    /* Miscellaneous info. */

    unsigned co_qthresh;    /* qtheta threshold */

    /* Ranker info */

    int     co_rankf;       /* special rank required */
    int     co_rcount;      /* number of alternatives so far */
    unsigned co_minrank;    /* minimum rank in list */
    UCHAR   co_order[MAXLISTALTS];/* order of the ranked list */
    ALTINFO co_ranklist[MAXLISTALTS];/* array of correction alternates */
} CORRECT;

#define Cominrank       Corinfo.co_minrank
#define Coorder         Corinfo.co_order
#define Coparam         Corinfo.co_param
#define Coqthresh       Corinfo.co_qthresh
#define Corankf         Corinfo.co_rankf
#define Coranklist      Corinfo.co_ranklist
#define Corcount        Corinfo.co_rcount

extern CORRECT Corinfo;         /* Information about the correction. */

#endif
