Skip to content

Commit

Permalink
follow upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
hfxunlp committed May 8, 2017
1 parent 8c0cd17 commit dfee4e0
Show file tree
Hide file tree
Showing 25 changed files with 64 additions and 47 deletions.
11 changes: 7 additions & 4 deletions devc/x64/glove/glove.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ typedef struct cooccur_rec {
real val;
} CREC;

int write_header=0; //0=no, 1=yes; writes vocab_size/vector_size as first line for use with some libraries, such as gensim.
int verbose = 2; // 0, 1, or 2
int use_unk_vec = 1; // 0 or 1
int num_threads = 8; // pthreads
Expand Down Expand Up @@ -93,8 +94,7 @@ inline real check_nan(real update) {
if (isnan(update) || isinf(update)) {
fprintf(stderr, "\ncaught NaN in update");
return 0.;
}
else {
} else {
return update;
}
}
Expand Down Expand Up @@ -231,6 +231,7 @@ int save_params(int nb_iter) {
fid = fopen(vocab_file, "r");
sprintf(format, "%%%ds", MAX_STRING_LENGTH);
if (fid == NULL) { fprintf(stderr, "Unable to open file %s.\n", vocab_file); return 1; }
if (write_header) fprintf(fout, "%ld %d\n", vocab_size, vector_size);
for (a = 0; a < vocab_size; a++) {
if (fscanf(fid, format, word) == 0) return 1;
// input vocab cannot contain special <unk> keyword
Expand Down Expand Up @@ -381,6 +382,8 @@ int main(int argc, char **argv) {
printf("Usage options:\n");
printf("\t-verbose <int>\n");
printf("\t\tSet verbosity: 0, 1, or 2 (default)\n");
printf("\t-write-header <int>\n");
printf("\t\tIf 1, write vocab_size/vector_size as first line. Do nothing if 0 (default).\n");
printf("\t-vector-size <int>\n");
printf("\t\tDimension of word vector representations (excluding bias term); default 50\n");
printf("\t-threads <int>\n");
Expand Down Expand Up @@ -415,8 +418,8 @@ int main(int argc, char **argv) {
printf("\nExample usage:\n");
printf("./glove -input-file cooccurrence.shuf.bin -vocab-file vocab.txt -save-file vectors -gradsq-file gradsq -verbose 2 -vector-size 100 -threads 16 -alpha 0.75 -x-max 100.0 -eta 0.05 -binary 2 -model 2\n\n");
result = 0;
}
else {
} else {
if ((i = find_arg((char *)"-write-header", argc, argv)) > 0) write_header = atoi(argv[i + 1]);
if ((i = find_arg((char *)"-verbose", argc, argv)) > 0) verbose = atoi(argv[i + 1]);
if ((i = find_arg((char *)"-vector-size", argc, argv)) > 0) vector_size = atoi(argv[i + 1]);
if ((i = find_arg((char *)"-iter", argc, argv)) > 0) num_iter = atoi(argv[i + 1]);
Expand Down
6 changes: 3 additions & 3 deletions devc/x64/glove/glove.layout
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Order=0
Focused=0
[Editor_0]
CursorCol=1
CursorRow=453
TopLine=427
CursorCol=2
CursorRow=462
TopLine=409
LeftChar=1
11 changes: 7 additions & 4 deletions devc/x86/glove/glove.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ typedef struct cooccur_rec {
real val;
} CREC;

int write_header=0; //0=no, 1=yes; writes vocab_size/vector_size as first line for use with some libraries, such as gensim.
int verbose = 2; // 0, 1, or 2
int use_unk_vec = 1; // 0 or 1
int num_threads = 8; // pthreads
Expand Down Expand Up @@ -93,8 +94,7 @@ inline real check_nan(real update) {
if (isnan(update) || isinf(update)) {
fprintf(stderr, "\ncaught NaN in update");
return 0.;
}
else {
} else {
return update;
}
}
Expand Down Expand Up @@ -231,6 +231,7 @@ int save_params(int nb_iter) {
fid = fopen(vocab_file, "r");
sprintf(format, "%%%ds", MAX_STRING_LENGTH);
if (fid == NULL) { fprintf(stderr, "Unable to open file %s.\n", vocab_file); return 1; }
if (write_header) fprintf(fout, "%ld %d\n", vocab_size, vector_size);
for (a = 0; a < vocab_size; a++) {
if (fscanf(fid, format, word) == 0) return 1;
// input vocab cannot contain special <unk> keyword
Expand Down Expand Up @@ -381,6 +382,8 @@ int main(int argc, char **argv) {
printf("Usage options:\n");
printf("\t-verbose <int>\n");
printf("\t\tSet verbosity: 0, 1, or 2 (default)\n");
printf("\t-write-header <int>\n");
printf("\t\tIf 1, write vocab_size/vector_size as first line. Do nothing if 0 (default).\n");
printf("\t-vector-size <int>\n");
printf("\t\tDimension of word vector representations (excluding bias term); default 50\n");
printf("\t-threads <int>\n");
Expand Down Expand Up @@ -415,8 +418,8 @@ int main(int argc, char **argv) {
printf("\nExample usage:\n");
printf("./glove -input-file cooccurrence.shuf.bin -vocab-file vocab.txt -save-file vectors -gradsq-file gradsq -verbose 2 -vector-size 100 -threads 16 -alpha 0.75 -x-max 100.0 -eta 0.05 -binary 2 -model 2\n\n");
result = 0;
}
else {
} else {
if ((i = find_arg((char *)"-write-header", argc, argv)) > 0) write_header = atoi(argv[i + 1]);
if ((i = find_arg((char *)"-verbose", argc, argv)) > 0) verbose = atoi(argv[i + 1]);
if ((i = find_arg((char *)"-vector-size", argc, argv)) > 0) vector_size = atoi(argv[i + 1]);
if ((i = find_arg((char *)"-iter", argc, argv)) > 0) num_iter = atoi(argv[i + 1]);
Expand Down
2 changes: 1 addition & 1 deletion devc/x86/glove/glove.layout
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Focused=0
[Editor_0]
CursorCol=55
CursorRow=19
TopLine=7
TopLine=10
LeftChar=1
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified vs/x64/glove/.vs/glove/v15/.suo
Binary file not shown.
Binary file modified vs/x64/glove/.vs/glove/v15/Browse.VC.db
Binary file not shown.
11 changes: 7 additions & 4 deletions vs/x64/glove/glove/glove.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ typedef struct cooccur_rec {
real val;
} CREC;

int write_header=0; //0=no, 1=yes; writes vocab_size/vector_size as first line for use with some libraries, such as gensim.
int verbose = 2; // 0, 1, or 2
int use_unk_vec = 1; // 0 or 1
int num_threads = 8; // pthreads
Expand Down Expand Up @@ -93,8 +94,7 @@ inline real check_nan(real update) {
if (isnan(update) || isinf(update)) {
fprintf(stderr, "\ncaught NaN in update");
return 0.;
}
else {
} else {
return update;
}
}
Expand Down Expand Up @@ -231,6 +231,7 @@ int save_params(int nb_iter) {
fid = fopen(vocab_file, "r");
sprintf(format, "%%%ds", MAX_STRING_LENGTH);
if (fid == NULL) { fprintf(stderr, "Unable to open file %s.\n", vocab_file); return 1; }
if (write_header) fprintf(fout, "%ld %d\n", vocab_size, vector_size);
for (a = 0; a < vocab_size; a++) {
if (fscanf(fid, format, word) == 0) return 1;
// input vocab cannot contain special <unk> keyword
Expand Down Expand Up @@ -381,6 +382,8 @@ int main(int argc, char **argv) {
printf("Usage options:\n");
printf("\t-verbose <int>\n");
printf("\t\tSet verbosity: 0, 1, or 2 (default)\n");
printf("\t-write-header <int>\n");
printf("\t\tIf 1, write vocab_size/vector_size as first line. Do nothing if 0 (default).\n");
printf("\t-vector-size <int>\n");
printf("\t\tDimension of word vector representations (excluding bias term); default 50\n");
printf("\t-threads <int>\n");
Expand Down Expand Up @@ -415,8 +418,8 @@ int main(int argc, char **argv) {
printf("\nExample usage:\n");
printf("./glove -input-file cooccurrence.shuf.bin -vocab-file vocab.txt -save-file vectors -gradsq-file gradsq -verbose 2 -vector-size 100 -threads 16 -alpha 0.75 -x-max 100.0 -eta 0.05 -binary 2 -model 2\n\n");
result = 0;
}
else {
} else {
if ((i = find_arg((char *)"-write-header", argc, argv)) > 0) write_header = atoi(argv[i + 1]);
if ((i = find_arg((char *)"-verbose", argc, argv)) > 0) verbose = atoi(argv[i + 1]);
if ((i = find_arg((char *)"-vector-size", argc, argv)) > 0) vector_size = atoi(argv[i + 1]);
if ((i = find_arg((char *)"-iter", argc, argv)) > 0) num_iter = atoi(argv[i + 1]);
Expand Down
26 changes: 15 additions & 11 deletions vs/x64/glove/glove/x64/Release/glove.log
Original file line number Diff line number Diff line change
Expand Up @@ -29,24 +29,28 @@ glove.c(231): warning C4996: 'fopen': This function or variable may be unsafe. C
C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(207): note: 参见“fopen”的声明
glove.c(232): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1772): note: 参见“sprintf”的声明
glove.c(235): warning C4996: 'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(234): warning C4477: “fprintf”: 格式字符串“%ld”需要类型“long”的参数,但可变参数 1 拥有了类型“__int64”
glove.c(234): note: 请考虑在格式字符串中使用“%lld”
glove.c(234): note: 请考虑在格式字符串中使用“%Id”
glove.c(234): note: 请考虑在格式字符串中使用“%I64d”
glove.c(236): warning C4996: 'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1195): note: 参见“fscanf”的声明
glove.c(254): warning C4996: 'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(255): warning C4996: 'fscanf': This function or variable may be unsafe. Consider using fscanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(1195): note: 参见“fscanf”的声明
glove.c(262): warning C4244: “初始化”: 从“__int64”转换到“int”,可能丢失数据
glove.c(303): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(263): warning C4244: “初始化”: 从“__int64”转换到“int”,可能丢失数据
glove.c(304): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(207): note: 参见“fopen”的声明
glove.c(337): warning C4996: 'localtime': This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(338): warning C4996: 'localtime': This function or variable may be unsafe. Consider using localtime_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\time.h(505): note: 参见“localtime”的声明
glove.c(432): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(433): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(434): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(435): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(436): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(437): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(438): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(440): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(441): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(442): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(446): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(443): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(444): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(445): warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
glove.c(449): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
C:\Program Files (x86)\Windows Kits\10\Include\10.0.15063.0\ucrt\stdio.h(207): note: 参见“fopen”的声明
正在生成代码
e:\ano\workspace\glove-win\vs\x64\glove\glove\glove.c(175): warning C4716: “glove_thread”: 必须返回一个值
Expand Down
Binary file modified vs/x64/glove/glove/x64/Release/glove.tlog/link.read.1.tlog
Binary file not shown.
Binary file modified vs/x64/glove/glove/x64/Release/vc141.pdb
Binary file not shown.
Binary file modified vs/x64/glove/x64/Release/glove.iobj
Binary file not shown.
Binary file modified vs/x64/glove/x64/Release/glove.ipdb
Binary file not shown.
Binary file modified vs/x64/glove/x64/Release/glove.pdb
Binary file not shown.
Binary file modified vs/x86/glove/.vs/glove/v15/.suo
Binary file not shown.
Binary file modified vs/x86/glove/.vs/glove/v15/Browse.VC.db
Binary file not shown.
Binary file modified vs/x86/glove/Release/glove.iobj
Binary file not shown.
Binary file modified vs/x86/glove/Release/glove.ipdb
Binary file not shown.
Binary file modified vs/x86/glove/Release/glove.pdb
Binary file not shown.
Loading

0 comments on commit dfee4e0

Please sign in to comment.