Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编译GEmode.cpp,然后运行乱码问题 #6

Open
dsj96 opened this issue Aug 18, 2020 · 10 comments
Open

编译GEmode.cpp,然后运行乱码问题 #6

dsj96 opened this issue Aug 18, 2020 · 10 comments

Comments

@dsj96
Copy link

dsj96 commented Aug 18, 2020

编译GEmode.cpp,然后运行后生成的net_time_vec.txt,net_word_vec.txt, net_reg_vec.txt, 和net_poi_vec.txt文件乱码,导致下面的topNscore.py无法运行,在GEmodel.cpp文件的OutputFile函数(line:589)做出了一些修改但不奏效,想问下楼主运行的时候乱码吗?

void OutputFile(char emb_file[100], int num_vertices, ClassVertex *vertex, real *emb_vertex){
	FILE *fo = fopen(emb_file, "wb");//修改为FILE *fo = fopen(emb_file, "w");
	std::cout<<"outputfile... "<<num_vertices<<"\n";
	// fprintf(fo, "%d %d\n", num_vertices, dim);
	for (int a = 0; a < num_vertices; a++)
	{
		//std::cout<<a<<"\n";
		//std::cout<<vertex[a].name<<"\n";
		fprintf(fo, "%s ", vertex[a].name);
		if (is_binary) for (int b = 0; b < dim; b++) fwrite(&emb_vertex[a * dim + b], sizeof(real), 1, fo);
		else for (int b = 0; b < dim; b++) fprintf(fo, "%lf ", emb_vertex[a * dim + b]);
		fprintf(fo, "\n");
	}
	fclose(fo);
}
@g101418
Copy link
Owner

g101418 commented Aug 18, 2020 via email

@dsj96
Copy link
Author

dsj96 commented Aug 19, 2020

嗯 好的谢谢回复,我再分析分析~

@prismheart
Copy link

嗯 好的谢谢回复,我再分析分析~
想问一下你的乱码问题解决了吗?我也是乱码,是输出的问题还是strcpy的问题啊?

@dsj96
Copy link
Author

dsj96 commented Dec 10, 2020

嗯 好的谢谢回复,我再分析分析~
想问一下你的乱码问题解决了吗?我也是乱码,是输出的问题还是strcpy的问题啊?
嗯 运行GEmodel的时候有一个binary的参数 设置为0,我是这样解决的

@prismheart
Copy link

谢谢了,我也发现了,是二进制fwrite和fprintf的原因

@Excuep
Copy link

Excuep commented Mar 16, 2021

编译GEmode.cpp,然后运行后生成的net_time_vec.txt,net_word_vec.txt, net_reg_vec.txt, 和net_poi_vec.txt文件乱码,导致下面的topNscore.py无法运行,在GEmodel.cpp文件的OutputFile函数(line:589)做出了一些修改但不奏效,想问下楼主运行的时候乱码吗?

void OutputFile(char emb_file[100], int num_vertices, ClassVertex *vertex, real *emb_vertex){
	FILE *fo = fopen(emb_file, "wb");//修改为FILE *fo = fopen(emb_file, "w");
	std::cout<<"outputfile... "<<num_vertices<<"\n";
	// fprintf(fo, "%d %d\n", num_vertices, dim);
	for (int a = 0; a < num_vertices; a++)
	{
		//std::cout<<a<<"\n";
		//std::cout<<vertex[a].name<<"\n";
		fprintf(fo, "%s ", vertex[a].name);
		if (is_binary) for (int b = 0; b < dim; b++) fwrite(&emb_vertex[a * dim + b], sizeof(real), 1, fo);
		else for (int b = 0; b < dim; b++) fprintf(fo, "%lf ", emb_vertex[a * dim + b]);
		fprintf(fo, "\n");
	}
	fclose(fo);
}

能不能留个联系方式,编译cpp一直出现问题,搞了一周还是没搞好。

@Excuep
Copy link

Excuep commented Mar 16, 2021

嗯 好的谢谢回复,我再分析分析~
想问一下你的乱码问题解决了吗?我也是乱码,是输出的问题还是strcpy的问题啊?

能不能留个联系方式,编译cpp一直出现问题,搞了一周还是没搞好。

@dsj96
Copy link
Author

dsj96 commented Mar 16, 2021

编译问题多半是环境的问题,你在Linux环境下试试,按照指南安装好Boost库,应该就没问题了,我在win10上也总是编译不通过,有的c++函数在win上和Linux上书写方式不同。

@Excuep
Copy link

Excuep commented Mar 16, 2021

我这边输出没有乱码,你看看有没有可能是编码的问题。

在 2020年8月18日,下午6:44,dsj96 @.***> 写道: 编译GEmode.cpp,然后运行后生成的net_time_vec.txt,net_word_vec.txt, net_reg_vec.txt, 和net_poi_vec.txt文件乱码,导致下面的topNscore.py无法运行,在GEmodel.cpp文件的OutputFile函数(line:589)做出了一些修改但不奏效,想问下楼主运行的时候乱码吗? c++ void OutputFile(char emb_file[100], int num_vertices, ClassVertex *vertex, real *emb_vertex){ FILE *fo = fopen(emb_file, "wb");//修改为FILE *fo = fopen(emb_file, "w"); std::cout<<"outputfile... "<<num_vertices<<"\n"; // fprintf(fo, "%d %d\n", num_vertices, dim); for (int a = 0; a < num_vertices; a++) { //std::cout<<a<<"\n"; //std::cout<<vertex[a].name<<"\n"; fprintf(fo, "%s ", vertex[a].name); if (is_binary) for (int b = 0; b < dim; b++) fwrite(&emb_vertex[a * dim + b], sizeof(real), 1, fo); else for (int b = 0; b < dim; b++) fprintf(fo, "%lf ", emb_vertex[a * dim + b]); fprintf(fo, "\n"); } fclose(fo); } — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#6>, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACYONAUBNRCHRZHJDLQNYTLSBJLSXANCNFSM4QDHX3RQ.

能不能留个联系方式,编译cpp一直出现问题,搞了一周还是没搞好。

@g101418
Copy link
Owner

g101418 commented Mar 16, 2021

编译问题多半是环境的问题,你在Linux环境下试试,按照指南安装好Boost库,应该就没问题了,我在win10上也总是编译不通过,有的c++函数在win上和Linux上书写方式不同。

对,我是在MacOS上编译的,论文作者提供的源代码应该是Windows平台的,我做了些修改。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants