Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
surmon-china committed Dec 1, 2017
1 parent bd446c0 commit 215ee8f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 27 deletions.
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# naivebayes

A Naive-Bayes classifier for node.js
Naive-Bayes classifier for node.js

适用于Node.js的用于文本学习的朴素贝叶斯算法库。

Expand All @@ -35,11 +35,11 @@ P(C|D) = P(D|C) * P(C) / P(D)
=> Wn.forEach(W => P(W|C)
```

# Example
## Demo

生成了Web版便于体验:[Web experience Page](https://surmon-china.github.io/naivebayes/)
生成了Web版便于体验:[Web Example Page](https://surmon-china.github.io/naivebayes/)

# What can I use this for?
## What can I use this for?

You can use this for categorizing any text content into any arbitrary set of **categories**. For example:

Expand All @@ -53,15 +53,15 @@ You can use this for categorizing any text content into any arbitrary set of **c
- 判断未知文本内容的分类,可以是任何你想要的维度
- ...

# Installing
## Installing

```
npm install naivebayes --save
```

# Usage
## Usage

## 基本方法
### 基本方法

```javascript
// 导入
Expand Down Expand Up @@ -89,7 +89,7 @@ const revivedClassifier = NaiveBayes.fromJson(stateJson)

```

## 实践场景
### 实践场景

```javascript
const NaiveBayes = require('naivebayes')
Expand Down Expand Up @@ -145,9 +145,9 @@ console.log('预期:正常,实际:', classifier.probabilities('马克思
// [{ category: 'xx', probability: xxx }, { ... }, ...]
```

# API
## API

## Class
### Class

```javascript
const classifier = new NaiveBayes([options])
Expand All @@ -170,7 +170,7 @@ const classifier = new NaiveBayes({
})
```

## Learn
### Learn

```javascript
classifier.learn(text, category)
Expand All @@ -180,7 +180,7 @@ classifier.learn(text, category)

Teach your classifier what `category` the `text` belongs to. The more you teach your classifier, the more reliable it becomes. It will use what it has learned to identify new documents that it hasn't seen before.

## Probabilities
### Probabilities

```javascript
classifier.probabilities(text)
Expand All @@ -190,7 +190,7 @@ classifier.probabilities(text)

Returns an array of `{ category, probability }` objects with probability calculated for each category. Its judgement is based on what you have taught it with `.learn()`.

## Categorize
### Categorize

```javascript
classifier.categorize(text ,[probability])
Expand All @@ -200,7 +200,7 @@ classifier.categorize(text ,[probability])

Returns the `category` it thinks `text` belongs to. Its judgement is based on what you have taught it with `.learn()`.

## ToJson
### ToJson

```javascript
classifier.toJson()
Expand All @@ -210,7 +210,7 @@ classifier.toJson()

Returns the JSON representation of a classifier. This is the same as `JSON.stringify(classifier.toJsonObject())`.

## ToJsonObject
### ToJsonObject

```javascript
classifier.toJsonObject()
Expand All @@ -220,7 +220,7 @@ classifier.toJsonObject()

Returns a JSON-friendly representation of the classifier as an `object`.

## FromJson
### FromJson

```javascript
const classifier = NaiveBayes.fromJson(jsonObject)
Expand All @@ -230,16 +230,16 @@ const classifier = NaiveBayes.fromJson(jsonObject)

Returns a classifier instance from the JSON representation. Use this with the JSON representation obtained from `classifier.toJson()`.

# 相关库
## 中文分词库:
## 相关库
### 中文分词库:
- [nodejieba](https://github.com/yanyiwu/nodejieba)
- [node-segment](https://github.com/leizongmin/node-segment)
- [china-address - 地址分词](https://github.com/booxood/china-address)
- [word-picker](https://github.com/redhu/word-picker)

## 英文分词库:
### 英文分词库:
- [tokenize-text](https://github.com/GitbookIO/tokenize-text)
- [tokenizer](https://github.com/bredele/tokenizer)

# Credits
## Credits
This project was forked from [bayes](https://github.com/ttezel/bayes) by @Tolga Tezel 👍
14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@
"main": "dist/naive-bayes.js",
"scripts": {
"dev": "nodemon --exec \"NODE_ENV=development node --harmony test.js\"",
"build": "babel lib --out-dir dist",
"test": "node test.js",
"build": "babel src --out-dir dist",
"test": "node test/index.js",
"deploy": "git push && npm publish && git push --tags"
},
"author": "Surmon",
"author": {
"name": "Surmon",
"email": "surmon@foxmail.com",
"url": "http://surmon.me"
},
"private": false,
"license": "MIT",
"devDependencies": {
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1"
"babel-preset-stage-2": "^6.24.1",
"segment": "^0.1.3"
}
}
File renamed without changes.
3 changes: 0 additions & 3 deletions test.js

This file was deleted.

3 changes: 3 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require('./base.js')
require('./incremental.js')
console.log('Tested!')

0 comments on commit 215ee8f

Please sign in to comment.