-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
75 lines (65 loc) · 1.64 KB
/
Copy pathmain.c
File metadata and controls
75 lines (65 loc) · 1.64 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
68
69
70
71
72
73
74
#include "gen.h"
#include "file.h"
#include <string.h>
#include <time.h>
int main(){
srand(time(NULL));
trees T = init_trees();
int size;
char** file = read_file("dictionnaire_non_accentue.txt", &size);
for (int i=0; i < size; ++i) edit_tree(T, file[i]);
char search[20];
int t;
char* phrase;
int end = 0;
do {
int prompt;
printf("0) Leave \n1) Generate a complete sentence \n2) Search with flechi words \n3) Other \n");
scanf("%d", &prompt);
if (prompt == 0) {
end = 1;
break;
}
else if (prompt == 1){
phrase = gen_phrase_flechie(T);
printf("%s\n", phrase);
free(phrase);
}
else if (prompt == 2) {
printf("search:");
scanf("%s", search);
flechi** res_fl = search_flechie(T, search, &t);
if (res_fl != NULL){
printf("Results:\n");
for (int i=0; i<t; ++i) display_flechie(res_fl[i]);
free(res_fl);
}
else printf("No results found\n");
}
else if (prompt == 3){
printf("0) Back to main menu \n1) Search with base words \n2) Random search into noun tree\n3) Generate a sentence with base words \n");
scanf("%d", &prompt);
if (prompt == 1) {
printf("search:");
scanf("%s", search);
p_node* res_pn = search_word(T, search, &t);
if (res_pn != NULL){
printf("Array of p_node:\n");
for (int i=0; i<t; ++i) display_node(res_pn[i]);
free(res_pn);
}
else printf("No results found\n");
}
else if (prompt == 2) display_node(random_word(T.tree_nom));
else if (prompt == 3){
phrase = gen_phrase_base(T);
printf("%s\n", phrase);
free(phrase);
}
}
printf("\n");
} while (end == 0);
free_file(file);
free_all(T);
return 0;
}