首页 新闻 会员 周边

scws中文分词工具分出来的怎么都是单字,求解

0
[已关闭问题] 关闭于 2017-05-23 16:40

问题描述:使用scws中文分词工具分词,结果分出来的都是单词,,使用了设定分词(scws_set_multi(s, SCWS_MULTI_SHORT);),还是一样,求解怎么破??

环境信息:centos6.5,64位,虚拟机,基于C/C++

代码如下:

#include <scws.h>

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
    scws_t s;
    scws_res_t res, cur;
    char *text = "我名字叫风孝忠我是一个中国人,我买Q币玩游戏,我懂C++语言,我爱工作我爱老板\n";

    if (!(s = scws_new()))
    {
        printf("error, can't init the scws_t!\n");
        exit(-1);
    }

    scws_set_charset(s, "gbk");
    scws_set_dict(s, "/usr/local/scws/etc/dict_chs_gbk.xdb", SCWS_XDICT_XDB);
    scws_set_rule(s, "/usr/local/scws/etc/rules.ini");
    
    //设定分词
    scws_set_multi(s, SCWS_MULTI_SHORT);    
    
    scws_send_text(s, text, strlen(text));
    while (res = cur = scws_get_result(s))
    {
        while (cur != NULL)
        {
            printf("WORD: %.*s/ %s (IDF = %4.2f)\n", cur->len, text+cur->off, cur->attr, cur->idf);
            cur = cur->next;
        }
        scws_free_result(res);
    }
    scws_free(s);
    
    return 0;
}

 

学海没有鱼的主页 学海没有鱼 | 初学一级 | 园豆:5
提问于:2017-05-23 11:09
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册