-
Notifications
You must be signed in to change notification settings - Fork 0
/
inverted.h
71 lines (54 loc) · 1.33 KB
/
inverted.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef INVERTED_INDEX_H
#define INVERTED_INDEX_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define SUCCESS 0
#define FAILURE -1
#define NOELEMENT -2
#define EMPTYLIST -3
#define REPEATED -4
#define FILE_EMPTY -5
#define NOT_PRESENT -6
#define SIZE 26
#define BUFF_SIZE 255
#define NAMELENGTH 50
//inverted table
typedef struct sub_node
{
char f_name[NAMELENGTH];
int w_count;
struct sub_node *link;
}sub_node_t;
typedef struct node
{
char word[NAMELENGTH];
struct node *link;
sub_node_t *sub_link;
int f_count;
}main_node_t;
typedef struct file_node
{
char f_name[NAMELENGTH];
struct file_node *link;
}Slist;
/* File validation */
int validate_n_store_filenames(Slist **, char *filenames[],int argc);
int IsFileValid(char *);
int store_filenames_to_list(char *f_name, Slist **head);
/*Create DB*/
int create_DB(Slist *file_head, main_node_t **head);
void read_datafile(Slist *, main_node_t **, char *f_name);
int insert_at_last_main(main_node_t **head, char *word);
int update_link_table(main_node_t **main_node);
int update_word_count(main_node_t **head);
/*Display*/
int display_DB(main_node_t **head);
/*search */
int search_DB(main_node_t **head, char *word);
/*Save*/
int save_DB(main_node_t **head, char *fname);
/*Update */
int update_DB(Slist **, main_node_t **, char *);
#endif