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

windows平台下ltp_test运行<arg />乱码 #116

Closed
skyhiter opened this issue Jun 18, 2015 · 13 comments
Closed

windows平台下ltp_test运行<arg />乱码 #116

skyhiter opened this issue Jun 18, 2015 · 13 comments
Labels
Milestone

Comments

@skyhiter
Copy link

ltp-3.3.0 release version
cmake2.8.12.2+VS2010编译,运行ltp_test,输出中的arg 的type属性值是乱码。Linux编译运行是没问题的。
注:输入输出都已转换为utf-8无bom格式。
win
linux
谢谢~~

@skyhiter skyhiter changed the title windows平台下ltp windows平台下ltp_test运行<arg />乱码 Jun 18, 2015
@Oneplus
Copy link
Member

Oneplus commented Jun 19, 2015

谢谢报bug,我们会尽快修复这个问题。

@HaomingFu
Copy link

我遇到的乱码问题更夸张。执行的命令是ltp_test.exe --input ltp_test.txt,运行环境是windows Visual Studio 2012;ltp_test.txt的内容是”爱上一匹野马,可我的家里没有草原。“,编码是utf-8 without BOM。运行结果是:
qq 20150717093914

另外我运行example文件夹中的程序的时候也同样得到乱码:
qq 20150720114027

一楼报告中说arg type的值是乱码,而我的情况更严重,分词结果都是乱码。因为云平台的分词是完全正确的,所以出现这种问题我也十分意外。这个bug改怎么解决?谢了。

@Oneplus
Copy link
Member

Oneplus commented Jul 20, 2015

这个是windows terminal显示utf8的问题

@HaomingFu
Copy link

Thanks go to Oneplus. 我后来写了一个测试程序,环境依然是Windows VS2012,文件编码是utf-8 without BOM。代码和运行结果如图示:
qq 20150720175326
qq 20150720175207

我认为是从文件读入中文数据有问题,因为我在debug我们的cws_cmdline项目的时候发现下面的代码(cws_cmdline.cpp的116行)产生error:
std::ifstream ifs(input.c_str());
Error Code: Error reading characters of string.
尽管产生了上面的error,但程序还是继续跑完,运行结果就是出现我在3楼报告的乱码。

我百度了一下解决方法,但目前还是没有找到。

@Oneplus
Copy link
Member

Oneplus commented Jul 20, 2015

是这样,windows终端是gbk编码。所以从终端输入的(std:cin)和向终端输出的(std::cout)字符串都被解释成gbk了。

而ltp向终端输出了一个utf8编码的字符串,如果被解释成gbk的,就会显示乱码。

所以在windows终端下使用ltp工作的方法是将待分析的数据用utf8保存,然后用<重定向到标准输入,对于ltp的输出,用>重定向到标准输出。然后用能够显示utf8编码的文本编辑器,比如notepad++打开文件查看结果。

@Oneplus
Copy link
Member

Oneplus commented Jul 20, 2015

@HaomingFu
Copy link

问题解决了。谢谢!

@endyul endyul removed this from the 3.3.1 improved sequence labeling milestone Jan 24, 2016
@endyul endyul added this to the 3.4.0 milestone Apr 1, 2016
@liquor7
Copy link

liquor7 commented Dec 12, 2016

请问你是怎么解决的?

@HaomingFu
Copy link

Oneplus已经给了回答了:http://ltp.readthedocs.org/zh_CN/latest/ltptest.html#id8

由于Windows终端采用gbk编码显示,运行 ltp_test 后会在终端输出乱码。您可以将标准输出重定向到文件,以UTF8方式查看文件,就可以解决乱码的问题。

@liquor7
Copy link

liquor7 commented Dec 13, 2016

请问你有在VS下运行成功过吗?

@pheelyli
Copy link

windows 终端显示utf-8的问题,可以先输入指令:
chcp 65001
然后就可以正常用utf-8 了

@endyul
Copy link

endyul commented Feb 14, 2017

@pheelyli 感谢反馈

@skyhiter
Copy link
Author

问题已解决,故关闭改问题。

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

No branches or pull requests

6 participants