forked from lmthang/bivec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runCLDC.c
75 lines (66 loc) · 2.81 KB
/
runCLDC.c
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
75
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#define MAX_STRING 1000
void execute(char* command){
// fprintf(stderr, "# Executing: %s\n", command);
system(command);
}
void cldcEvaluate(char* outPrefix, int iter) {
char command[MAX_STRING];
/* de2en */
// prepare data
chdir("cldc/scripts/de2en");
if(iter<0) { // full evaluation
sprintf(command, "./prepare-data-klement-4cat-train-valid-my-embeddings.ch %s", outPrefix); execute(command);
sprintf(command, "./prepare-data-klement-4cat-all-sizes-my-embeddings.ch %s", outPrefix); execute(command);
} else {
sprintf(command, "./prepare-data-klement-4cat-1000-my-embeddings.ch %s", outPrefix); execute(command);
}
// run perceptron
if(iter<0) { // full evaluation
sprintf(command, "./run-perceptron-train-valid-my-embeddings.ch %s", outPrefix); execute(command);
sprintf(command, "./run-perceptron-all-sizes-my-embeddings.ch %s", outPrefix); execute(command);
system("");
} else {
fprintf(stderr, "# eval %d %s %s", iter, "de2en", "cldc");
sprintf(command, "./run-perceptron-1000-my-embeddings.ch %s", outPrefix); execute(command);
}
/** en2de **/
// prepare data
chdir("../en2de");
if(iter<0) { // full evaluation
sprintf(command, "./prepare-data-klement-4cat-train-valid-my-embeddings.ch %s", outPrefix); execute(command);
sprintf(command, "./prepare-data-klement-4cat-all-sizes-my-embeddings.ch %s", outPrefix); execute(command);
} else {
sprintf(command, "./prepare-data-klement-4cat-1000-my-embeddings.ch %s", outPrefix); execute(command);
}
// run perceptron
if(iter<0) { // full evaluation
sprintf(command, "./run-perceptron-train-valid-my-embeddings.ch %s", outPrefix); execute(command);
sprintf(command, "./run-perceptron-all-sizes-my-embeddings.ch %s", outPrefix); execute(command);
system("");
} else {
fprintf(stderr, "# eval %d %s %s", iter, "en2de", "cldc");
sprintf(command, "./run-perceptron-1000-my-embeddings.ch %s", outPrefix); execute(command);
}
chdir("../../..");
}
int main(int argc, char **argv) {
if (argc == 1) {
printf("runCLDC <prefix>\n\n");
exit(1);
}
char out_prefix[MAX_STRING];
strcpy(out_prefix, argv[1]);
// char *outPrefix = (char*)"/Users/phamhyhieu/Code/word2vec/data/klementiev-40/original";
// char *outPrefix = (char*)"/Users/phamhyhieu/Code/word2vec/data/hermann-128/add";
// char *outPrefix = (char*)"/Users/phamhyhieu/Code/word2vec/data/hermann-128/bi";
// char *outPrefix = (char*)"/Users/phamhyhieu/Code/word2vec/data/hermann-128/bi_plus";
// char *outPrefix = (char*)"/Users/phamhyhieu/Code/word2vec/data/hermann-128/add_plus";
// char *outPrefix = (char*)"/Users/phamhyhieu/Code/word2vec/data/sarath-40/sarath.40";
printf("# Run CLDC on %s\n", out_prefix);
cldcEvaluate(out_prefix, 0);
return 0;
}