您的位置:首页 > 其它

关于weka的TextDirectoryLoader 的一点记录

2011-04-08 15:27 176 查看
事实上,weka的fileEncoding已经设置为utf-8, 但是利用TextDirectoryLoader生成的arff文件里还是乱码。。。(并且对原来文件夹下的txt文件检查发现,文件虽然保存的是utf-8格式的,但是并没有开始的BOM标志 Byte Order Mark).于是在网上搜寻了好久也不知道如何解决,最后发现了这篇文章:http://old.nabble.com/Converting-a-directory-containing-UTF-8-files-into-arff-using-TextDirectoryLoader-td31217060.html 里面指出来, "Finally I guess I have managed to figure out the problem. In the

'TextDirectoryLoader' class (the class which is apparently used to
read and load a directory in Weka) 'BufferedInputStream' is used to
read the files in the directory (in Weka 3-7-3), in which it is not
possible to specify the charset. I changed that to 'BufferedReader'
and the charset was specified as 'UTF-8' in the constructor. And now

it is working perfectly. " 虽然按照作者的指示,将函数进行了一个替换,但是javac的时候还是有问题。。最终发现回复当中说weka-3-stable版本中已经解决了这个问题,就是在命令行option中加入了一个 charset选项,以标明输入的text文件的编码格式~~ 于是重新down下来weka-3-stable版本的weka-src,然后重新编译运行。done~ 最后的arff文件里就能正常的现实中文了~~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: