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

貌似不支持 中英混合分词 #11

Closed
cnzoupeng opened this issue Sep 4, 2015 · 4 comments
Closed

貌似不支持 中英混合分词 #11

cnzoupeng opened this issue Sep 4, 2015 · 4 comments

Comments

@cnzoupeng
Copy link

var Scws = require("scws");

var settings = {
charset: 'utf8',
ignorePunct: true,
debug: true
}
var scws = new Scws.init(settings);

var txt2 = "引言 VMwareTools 是 VMware 虚拟机中很重要的一个工具包,有些时候在虚拟机中安装完操作系统会缺少网卡驱动,不能上网,这时只要安装 VMwareTools 就可以解决问题,下面以 CentOS 为例,来说明 VMwareTools 的安装方法";
var ret = scws.segment(txt2);
var strNew = [];
for(var i in ret){
strNew.push(ret[i].word);
}
console.log(strNew.join(' '));
scws.destroy();

[root@localhost scws]# node app.js
引言

@dotSlashLu
Copy link
Owner

谢谢你的issue,你遇到的问题可能有两个原因:

  1. 需要字典和rules,你需要在settings中添加dict和rule设置,参考https://github.com/dotSlashLu/nodescws#new-scwsinitsettings ,附带的词典在项目的dicts下面,规则在项目的rules下,以dict为例,如果你在你的项目根目录下,路径就是./node_modules/scws/dicts/xxx.xdb。
  2. nodejs版本问题,刚发现从v0.12开始,nodejs的C++ API大变(https://strongloop.com/strongblog/node-js-v0-12-c-apis-breaking/ ),造成了大量原生addmon不能编译,如果是这个原因的话非常抱歉,由于api变更太大,需要重写的地方很多,修复这个问题需要一定时间,你可以使用别的类似插件。

如果你配好了dict和rule,而且node版本低于0.12,问题仍然呈现,请给我你的node版本我来跟进修复。

@jjhesk
Copy link

jjhesk commented Aug 23, 2016

Cannot compiled with nodejs 4.5..

n file included from ../src/nodescws.cc:5:0:
../node_modules/nan/nan.h:324:27: error: redefinition of ‘template<class T> v8::Local<T> Nan::imp::NanEnsureHandleOrPersistent(const v8::Local<T>&)’
   NAN_INLINE v8::Local<T> NanEnsureHandleOrPersistent(const v8::Local<T> &val) {
                           ^
../node_modules/nan/nan.h:319:17: note: ‘template<class T> v8::Handle<T> Nan::imp::NanEnsureHandleOrPersistent(v8::Handle<T>&)’ previously declared here
   v8::Handle<T> NanEnsureHandleOrPersistent(const v8::Handle<T> &val) {
                 ^
../node_modules/nan/nan.h:344:27: error: redefinition of ‘template<class T> v8::Local<T> Nan::imp::NanEnsureLocal(v8::Handle<T>&)’
   NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Handle<T> &val) {
                           ^
../node_modules/nan/nan.h:334:27: note: ‘template<class T> v8::Local<T> Nan::imp::NanEnsureLocal(const v8::Local<T>&)’ previously declared here
   NAN_INLINE v8::Local<T> NanEnsureLocal(const v8::Local<T> &val) {

@dotSlashLu
Copy link
Owner

dotSlashLu commented Aug 25, 2016

@jjhesk Hi, thanks for trying, since the huge change of the C++ addon API from node.js, it's only compatible with node version <= 0.12, for now. But I'll seek out a way to update this project recently. Stay tuned if you'll still need this. For now I suggest you use the command line version of scws.

dotSlashLu pushed a commit that referenced this issue Sep 5, 2016
add pointer check before doing segment(close #12)
@dotSlashLu
Copy link
Owner

Hi @cnzoupeng,验证了一下是上一版引进的一个bug,已经在刚发布的v0.5.0 修复了,感谢。
Hi @jjhesk I just released v0.5.0, now it supports node.js through v0.8 to 6.

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

3 participants