#ifndef _WFTABLE_H_
#define _WFTABLE_H_

#import <stdio.h>

/*
 * A Word Frequency Table (WFTable) is a hashed image of
 * a word histogram.  The data structure is fairly compact,
 * and includes a hash table so that functions like
 *	frequency(word,table)
 * can be easily implemented.  Tables can be read from
 * and written to files efficiently.
 */
typedef struct {
	long total;	/* total number of words in sample */
	long unique;	/* number of unique words in sample */
	long textSize;	/* number of bytes of 'text' */
	long tableSize;	/* number of *entries* in 'table' */
	char *text;	/* string of "word\0rank count word\0rank count..." */
	long *table;	/* pointers into text vector */
} WFTable;

extern WFTable *makeWFTableFromHistogram(char *file, FILE *fp);
extern char *findWFTable(char *file);
extern WFTable *readWFTable(char *file);
extern int writeWFTable(WFTable *t, char *file);
extern intfreeWFTable(WFTable *t);
extern WFTable *DefaultLanguageWFTable(void);
extern unsigned long wordStat(register char *word, WFTable *t, long *rank);
extern unsigned long wordRank(register char *word, WFTable *t);
extern unsigned long wordCount(register char *word, WFTable *t);
extern float wordFrequency(char *word, WFTable *t);
extern double wordPeculiarity(char *s, double count, double total, WFTable *t);

#endif

