关于weka的TextDirectoryLoader 的一点记录

事实上,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文件里就能正常的现实中文了~~

 

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值