Comparing version 0.2.13 to 1.0.0
# ChangeLog | ||
## v1.0.0 | ||
* 使用[CppJieba] v3.0.0 版本,使用更简洁的接口函数,可以使用参数指定切词方法。 | ||
* `require("nodejieba")` 时自动载入词典,用户无需再烦心字典的事情,实现即插即用。 | ||
* 听从 [issue23] 的建议,废除异步调用的接口,现在的接口函数都是同步调用函数,分别是 `cut`, `tag`, `extract` 。因为分词毕竟是CPU密集型的事情,没必要使用异步调用。 | ||
## v0.2.13 | ||
@@ -86,1 +92,2 @@ | ||
[nan]:https://github.com/nodejs/nan/ | ||
[issue23]:https://github.com/yanyiwu/nodejieba/issues/23 |
19
index.js
@@ -1,8 +0,13 @@ | ||
var segment = require("./build/Release/segment"); | ||
segment.DEFAULT_DICT = __dirname + "/dict/jieba.dict.utf8", | ||
segment.DEFAULT_HMM_DICT = __dirname + "/dict/hmm_model.utf8", | ||
segment.DEFAULT_USER_DICT = __dirname + "/dict/user.dict.utf8"; | ||
segment.DEFAULT_IDF_DICT = __dirname + "/dict/idf.utf8"; | ||
segment.DEFAULT_STOP_WORD_DICT = __dirname + "/dict/stop_words.utf8"; | ||
var nodejieba = require("./build/Release/nodejieba"); | ||
nodejieba.DEFAULT_DICT = __dirname + "/dict/jieba.dict.utf8", | ||
nodejieba.DEFAULT_HMM_DICT = __dirname + "/dict/hmm_model.utf8", | ||
nodejieba.DEFAULT_USER_DICT = __dirname + "/dict/user.dict.utf8"; | ||
nodejieba.DEFAULT_IDF_DICT = __dirname + "/dict/idf.utf8"; | ||
nodejieba.DEFAULT_STOP_WORD_DICT = __dirname + "/dict/stop_words.utf8"; | ||
module.exports = segment; | ||
nodejieba.load(nodejieba.DEFAULT_DICT, | ||
nodejieba.DEFAULT_HMM_DICT, | ||
nodejieba.DEFAULT_USER_DICT, | ||
nodejieba.DEFAULT_IDF_DICT, | ||
nodejieba.DEFAULT_STOP_WORD_DICT); | ||
module.exports = nodejieba; |
{ | ||
"name": "nodejieba", | ||
"description": "chinese segment for node", | ||
"version": "0.2.13", | ||
"description": "chinese word segmentation for node", | ||
"version": "1.0.0", | ||
"author": "Yanyi Wu <i@yanyiwu.com>", | ||
@@ -28,5 +28,5 @@ "maintainers": [ | ||
"scripts": { | ||
"test": "node test/segment.js && node test/query_segment.js && node test/pos_tagger.js && node test/keyword.js" | ||
"test": "node test/test.js" | ||
}, | ||
"license": "MIT" | ||
} |
@@ -38,67 +38,12 @@ [![Build Status](https://travis-ci.org/yanyiwu/nodejieba.png?branch=master)](https://travis-ci.org/yanyiwu/nodejieba) | ||
var nodejieba = require("nodejieba"); | ||
nodejieba.loadDict(nodejieba.DEFAULT_DICT, nodejieba.DEFAULT_HMM_DICT, nodejieba.DEFAULT_USER_DICT); | ||
# require 时自动载入词典。 | ||
``` | ||
#### 阻塞式调用 | ||
```js | ||
var wordList = nodejieba.cutSync("阻塞模式分词"); | ||
if (wordList.constructor == Array) // just for tutorial, this is always be true | ||
{ | ||
wordList.forEach(function(word) { | ||
console.log(word); | ||
}); | ||
} | ||
``` | ||
#### 非阻塞式调用 | ||
```js | ||
nodejieba.cut("非阻塞模式分词", function(wordList) { | ||
wordList.forEach(function(word) { | ||
console.log(word); | ||
}); | ||
}); | ||
``` | ||
### 搜索引擎分词算法 | ||
#### 初始化 | ||
```js | ||
var nodejieba = require("nodejieba"); | ||
nodejieba.queryLoadDict(nodejieba.DEFAULT_DICT, nodejieba.DEFAULT_HMM_DICT); | ||
``` | ||
#### 阻塞式调用 | ||
```js | ||
var wordList = nodejieba.queryCutSync("阻塞模式分词"); | ||
if (wordList.constructor == Array) // just for tutorial, this is always be true | ||
{ | ||
wordList.forEach(function(word) { | ||
console.log(word); | ||
}); | ||
} | ||
``` | ||
#### 非阻塞式调用 | ||
```js | ||
nodejieba.queryCut("非阻塞模式分词", function(wordList) { | ||
wordList.forEach(function(word) { | ||
console.log(word); | ||
}); | ||
}); | ||
``` | ||
具体用法可以参考 `test/segment.js test/query_segment.js` | ||
### 词性标注 | ||
具体用法可以参考 `test/pos_tagger.js` | ||
具体用法可以参考 `test/test.js` | ||
### 关键词抽取 | ||
具体用法可以参考 `test/keyword.js` | ||
具体用法可以参考 `test/test.js` | ||
@@ -105,0 +50,0 @@ ## 测试 |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
11700712
51
31
72