当前位置:Gxlcms > PHP教程 > 有用过php+SCWS的吗?有有关问题,没实现分词,只是分字

有用过php+SCWS的吗?有有关问题,没实现分词,只是分字

时间:2021-07-01 10:21:17 帮助过:5人阅读

有用过php+SCWS的吗? 有问题,没实现分词,只是分字。
有用过php+SCWS的吗? 有问题,没实现分词,只是分字。

phpinfo里已经有了
scws

SCWS support Enabled
SCWS Description Simple Chinese Words Segmentation
PECL Module version 0.2.2
SCWS Library 1.2.2
SCWS BugReport http://www.xunsearch.com/scws

但是如下的代码

$str="考试前20分钟,凭准考证和身份证进入考场,对号入座,并将准考证、身份证放在桌面右上角";
$so = scws_new();
$so->send_text($str);
$temp=$so->get_result();
$so->close();
print_r($temp);
?>

只能产生如下的结果


Array
(
[0] => Array
(
[word] => 考
[off] => 0
[len] => 3
[idf] => 0
[attr] => un
)

[1] => Array
(
[word] => 试
[off] => 3
[len] => 3
[idf] => 0
[attr] => un
)

[2] => Array
(
[word] => 前
[off] => 6
[len] => 3
[idf] => 0
[attr] => un
)

[3] => Array
(
[word] => 20
[off] => 9
[len] => 2
[idf] => 0
[attr] => un
)

[4] => Array
(
[word] => 分
[off] => 11
[len] => 3
[idf] => 0
[attr] => un
)

[5] => Array
(
[word] => 钟
[off] => 14
[len] => 3
[idf] => 0
[attr] => un
)

[6] => Array
(
[word] => ,
[off] => 17
[len] => 3
[idf] => 0
[attr] => un
)

[7] => Array
(
[word] => 凭
[off] => 20
[len] => 3
[idf] => 0
[attr] => un
)

[8] => Array
(
[word] => 准
[off] => 23
[len] => 3
[idf] => 0
[attr] => un
)

[9] => Array
(
[word] => 考
[off] => 26
[len] => 3
[idf] => 0
[attr] => un
)

[10] => Array
(
[word] => 证
[off] => 29
[len] => 3
[idf] => 0
[attr] => un
)

[11] => Array
(
[word] => 和
[off] => 32
[len] => 3
[idf] => 0
[attr] => un
)

[12] => Array
(
[word] => 身
[off] => 35
[len] => 3
[idf] => 0
[attr] => un
)

[13] => Array
(
[word] => 份
[off] => 38
[len] => 3
[idf] => 0
[attr] => un
)

[14] => Array
(
[word] => 证
[off] => 41
[len] => 3
[idf] => 0
[attr] => un
)

[15] => Array
(
[word] => 进
[off] => 44
[len] => 3
[idf] => 0
[attr] => un
)

[16] => Array
(
[word] => 入
[off] => 47
[len] => 3
[idf] => 0
[attr] => un
)

[17] => Array
(
[word] => 考
[off] => 50
[len] => 3
[idf] => 0
[attr] => un
)

[18] => Array
(
[word] => 场
[off] => 53
[len] => 3
[idf] => 0
[attr] => un
)

[19] => Array
(
[word] => ,
[off] => 56
[len] => 3
[idf] => 0
[attr] => un
)

[20] => Array
(
[word] => 对
[off] => 59
[len] => 3
[idf] => 0
[attr] => un
)

[21] => Array
(
[word] => 号
[off] => 62
[len] => 3
[idf] => 0
[attr] => un
)

[22] => Array
(
[word] => 入
[off] => 65
[len] => 3
[idf] => 0
[attr] => un
)

[23] => Array
(
[word] => 座
[off] => 68
[len] => 3
[idf] => 0
[attr] => un
)

[24] => Array
(
[word] => ,
[off] => 71
[len] => 3
[idf] => 0
[attr] => un
)

[25] => Array
(
[word] => 并
[off] => 74
[len] => 3
[idf] => 0
[attr] => un
)

[26] => Array
(
[word] => 将
[off] => 77
[len] => 3
[idf] => 0
[attr] => un
)

[27] => Array
(
[word] => 准
[off] => 80
[len] => 3
[idf] => 0
[attr] => un
)

[28] => Array
(
[word] => 考
[off] => 83
[len] => 3
[idf] => 0
[attr] => un
)

[29] => Array
(
[word] => 证
[off] => 86
[len] => 3
[idf] => 0
[attr] => un
)

[30] => Array
(
[word] => 、
[off] => 89
[len] => 3
[idf] => 0
[attr] => un
)

[31] => Array
(
[word] => 身
[off] => 92
[len] => 3
[idf] => 0
[attr] => un
)

[32] => Array
(
[word] => 份
[off] => 95
[len] => 3
[idf] => 0
[attr] => un
)

[33] => Array
(
[word] => 证
[off] => 98
[len] => 3
[idf] => 0
[attr] => un
)

[34] => Array
(
[word] => 放
[off] => 101
[len] => 3
[idf] => 0
[attr] => un
)

[35] => Array
(
[word] => 在
[off] => 104
[len] => 3
[idf] => 0
[attr] => un
)

[36] => Array
(
[word] => 桌
[off] => 107
[len] => 3
[idf] => 0
[attr] => un
)

[37] => Array
(
[word] => 面
[off] => 110
[len] => 3
[idf] => 0
[attr] => un
)

[38] => Array
(
[word] => 右
[off] => 113
[len] => 3
[idf] => 0
[attr] => un
)

[39] => Array
(
[word] => 上
[off] => 116
[len] => 3
[idf] => 0
[attr] => un
)

[40] => Array
(
[word] => 角
[off] => 119
[len] => 3
[idf] => 0
[attr] => un
)

)


我是按照官方的文档安装的。难道是还需要额外的配置吗?
------解决思路----------------------
字典路径没有配置好吧?
或者是字符集不对

人气教程排行