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

BUG: 被忽略的空格 #8

Open
hotoo opened this issue Nov 16, 2013 · 10 comments
Open

BUG: 被忽略的空格 #8

hotoo opened this issue Nov 16, 2013 · 10 comments
Labels

Comments

@hotoo
Copy link

hotoo commented Nov 16, 2013

console.log(segment.doSegment("a a")); // [ { w: 'a', p: 16 }, { w: 'a', p: 16 } ]
console.log(segment.doSegment("一 一")); // [ { w: '一一', p: 6291456 } ]
@leizongmin
Copy link
Owner

不好意思,过了这么久才看到

@leizongmin
Copy link
Owner

建议在分词前使用 split(/\s+/) 来分割

@hotoo
Copy link
Author

hotoo commented Nov 25, 2013

这个不准备修复了么?

@leizongmin
Copy link
Owner

1、导致自动把一 一合并的原因是:分词过程中是没有记录空格的,因此一 一的分词结果是['一', '一'],由于默认启用了一个优化功能,把相邻两个数字合并了;
2、如果要修复的话,目前最简单的方法就是分词前使用 split(/\s+/) 来分割一次;
3、如果直接在 segment 模块中修复的话,我需要再考虑一下这个改动是否会对一些现有的程序产生影响。

@leizongmin
Copy link
Owner

已修复。请使用 v0.0.5 版本

@hotoo
Copy link
Author

hotoo commented Dec 9, 2013

👍 建议仓库打上 tag,用 milestones, release 这些管理起来。

@leizongmin
Copy link
Owner

OK,已打上标签“v0.0.5”
在 Node.js 上使用,直接用 npm install [email protected] 即可安装指定版本

@hotoo
Copy link
Author

hotoo commented Jan 15, 2014

还是有问题,建议 Reopen。

0.0.5 版把空白字符当前分词要素,但是最终结果中还是忽略了空白字符本身:

segment.doSegment("a a")
// 输出结果:
[ { w: 'a', p: 16 }, { w: 'a', p: 16 } ]
// 正确结果应该是:
[ { w: 'a', p: 16 }, { w: ' ', p: 16 }, { w: 'a', p: 16 } ]

@leizongmin leizongmin reopened this Jan 15, 2014
@leizongmin
Copy link
Owner

这不是Bug,而是设计的时候分词结果自动去掉了“无用”的空白字符。

不知道是否有必要保留这些空格

@hotoo
Copy link
Author

hotoo commented Jan 15, 2014

程序处理的时候,空白文本是内容的一部分,不应该被忽略掉。
pinyin 处理时,分词模块忽略空白字符,会导致输出不一致:

han = "a a";
py = pinyin(han);
// 如果分词模块忽略掉空白字符:
py === "aa";
// 正确的应该是。
py === "a a";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants