#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <conio.h>
#include <ctype.h>
#define OK 1
#define ERROR 0
#define TRUE 1
#define FALSE 0
#define OVERFLOW -2
#define MaxBookNum 1000 //假设只对1000本书建立索引表(1000)
#define MaxKeyNum 2500 //索引表的最大容量(2500)
#define MaxLineLen 500 //书目串的最大长度(500)
#define MaxWordNum 10 //词表的最大容量
#define MaxWordLength 30 //单词的最大长度
typedef int Status;
typedef int ElemType; //定义链表的数据元素类型为整型
typedef int Boolean;
typedef struct
{
char item[MaxWordNum][MaxWordLength]; //字符串的数组
int last; //词表的长度
}WordListType; //词表的类型(顺序表)
typedef struct
{
char *ch; //如果是非空串,则按串长分配存储区,否则ch为NULL
int length; //串长度
}HString;
typedef struct LNode
{
ElemType data;
struct LNode *next;
}LNode,*Link,*Position;
typedef struct
{
Link head,tail;
int len;
}LinkList;
typedef struct
{
HString key; //关键词
LinkList bnolist; //存放书号索引的链表
}IdxTermType; //索引项类型
typedef struct
{
IdxTermType item[MaxKeyNum+1];
int last;
}IdxListType; //索引表类型
//----------------主要变量--------------
char buf[MaxLineLen]; //书目串缓冲区
WordListType wdlist; //关键字词表
IdxListType idxlist; //索引表
char oftenwords[6][10] = {
"an","a","of","and","to","the"};
/*******************************声明部分****************************************/
//--------------基本操作---------
void InitIdxList (IdxListType *idxlist);
//初始化操作,置索引表idxlist为空表,且在idxlist.item[0]设一空串
void GetLine (FILE *f);
//从文件F读入一个书目信息到书目串缓冲区buf
void ExtractKeyWord (int *Num);
//Status ExtractKeyWord(char* Buffer,WordListType *w,int *Num);
//从buf中提取书名关键词到词表wdlist
【数据结构】算法4.9-4.14 建立词索引表
最新推荐文章于 2023-05-30 09:15:15 发布