1 | #include "dbgen_gunk.hpp" |
2 | |
3 | #include "dss.h" |
4 | #include "dsstypes.h" |
5 | |
6 | void load_dists(void) { |
7 | read_dist(env_config(DIST_TAG, DIST_DFLT), "p_cntr" , &p_cntr_set); |
8 | read_dist(env_config(DIST_TAG, DIST_DFLT), "colors" , &colors); |
9 | read_dist(env_config(DIST_TAG, DIST_DFLT), "p_types" , &p_types_set); |
10 | read_dist(env_config(DIST_TAG, DIST_DFLT), "nations" , &nations); |
11 | read_dist(env_config(DIST_TAG, DIST_DFLT), "regions" , ®ions); |
12 | read_dist(env_config(DIST_TAG, DIST_DFLT), "o_oprio" , &o_priority_set); |
13 | read_dist(env_config(DIST_TAG, DIST_DFLT), "instruct" , &l_instruct_set); |
14 | read_dist(env_config(DIST_TAG, DIST_DFLT), "smode" , &l_smode_set); |
15 | read_dist(env_config(DIST_TAG, DIST_DFLT), "category" , &l_category_set); |
16 | read_dist(env_config(DIST_TAG, DIST_DFLT), "rflag" , &l_rflag_set); |
17 | read_dist(env_config(DIST_TAG, DIST_DFLT), "msegmnt" , &c_mseg_set); |
18 | |
19 | /* load the distributions that contain text generation */ |
20 | read_dist(env_config(DIST_TAG, DIST_DFLT), "nouns" , &nouns); |
21 | read_dist(env_config(DIST_TAG, DIST_DFLT), "verbs" , &verbs); |
22 | read_dist(env_config(DIST_TAG, DIST_DFLT), "adjectives" , &adjectives); |
23 | read_dist(env_config(DIST_TAG, DIST_DFLT), "adverbs" , &adverbs); |
24 | read_dist(env_config(DIST_TAG, DIST_DFLT), "auxillaries" , &auxillaries); |
25 | read_dist(env_config(DIST_TAG, DIST_DFLT), "terminators" , &terminators); |
26 | read_dist(env_config(DIST_TAG, DIST_DFLT), "articles" , &articles); |
27 | read_dist(env_config(DIST_TAG, DIST_DFLT), "prepositions" , &prepositions); |
28 | read_dist(env_config(DIST_TAG, DIST_DFLT), "grammar" , &grammar); |
29 | read_dist(env_config(DIST_TAG, DIST_DFLT), "np" , &np); |
30 | read_dist(env_config(DIST_TAG, DIST_DFLT), "vp" , &vp); |
31 | } |
32 | |
33 | static void cleanup_dist(distribution *target) { |
34 | if (!target) { |
35 | return; |
36 | } |
37 | if (target->list) { |
38 | for (int i = 0; i < target->count; i++) { |
39 | if (target->list[i].text) { |
40 | free(target->list[i].text); |
41 | } |
42 | } |
43 | free(target->list); |
44 | } |
45 | } |
46 | |
47 | void cleanup_dists(void) { |
48 | cleanup_dist(&p_cntr_set); |
49 | cleanup_dist(&colors); |
50 | cleanup_dist(&p_types_set); |
51 | cleanup_dist(&nations); |
52 | cleanup_dist(®ions); |
53 | cleanup_dist(&o_priority_set); |
54 | cleanup_dist(&l_instruct_set); |
55 | cleanup_dist(&l_smode_set); |
56 | cleanup_dist(&l_category_set); |
57 | cleanup_dist(&l_rflag_set); |
58 | cleanup_dist(&c_mseg_set); |
59 | cleanup_dist(&nouns); |
60 | cleanup_dist(&verbs); |
61 | cleanup_dist(&adjectives); |
62 | cleanup_dist(&adverbs); |
63 | cleanup_dist(&auxillaries); |
64 | cleanup_dist(&terminators); |
65 | cleanup_dist(&articles); |
66 | cleanup_dist(&prepositions); |
67 | cleanup_dist(&grammar); |
68 | cleanup_dist(&np); |
69 | cleanup_dist(&vp); |
70 | } |
71 | |