-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
67 lines (52 loc) · 1.69 KB
/
main.cpp
File metadata and controls
67 lines (52 loc) · 1.69 KB
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
#include <stdio.h>
#include <stdlib.h>
#include "include/config.h"
#include "list/list.h"
#include "include/text.h"
#include "hashtable/hashtable.h"
#include "list/list_dump.h"
int main (int argc, char *argv[])
{
log_init("hashtable_logs.html");
FILE *input_file = fopen("input.txt", "r");
text_t text = {};
get_text(input_file, &text, "input.txt");
fclose(input_file);
delete_punctuations(&text);
divide_text_on_words(&text);
#ifdef PRE_ALIGNED_WORDS
align_words(&text);
#endif /*PRE_ALIGNED_WORDS*/
char hash_mode = 0;
if (argc == 1)
hash_mode = 0;
else
hash_mode = *argv[1];
hashtable_t hashtable = {};
hashtable_ctor(&hashtable, HASHTABLE_SIZE);
hash_words(&text, &hashtable, hash_mode);
FILE *file_to_find = fopen("to_find.txt", "r");
if (!file_to_find) {
log(1, "NULL FILE PTR.");
text_dtor(&text);
hashtable_dtor(&hashtable);
log_dtor();
return NULL_FILE_PTR;
}
text_t text_words2find = {};
get_text(file_to_find, &text_words2find, "to_find.txt");
fclose(file_to_find);
delete_punctuations(&text_words2find);
divide_text_on_words(&text_words2find);
#ifdef PRE_ALIGNED_WORDS
align_words(&text_words2find);
#endif /*PRE_ALIGNED_WORDS*/
for (int i = 0; i < 50; i++) {
find_words_crc32(&hashtable, text_words2find.words, text_words2find.n_words);
}
text_dtor(&text);
text_dtor(&text_words2find);
hashtable_dtor(&hashtable);
log_dtor();
return 0;
}