定制 kbariotis/documer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

kbariotis/documer

最新稳定版本:0.2.3

Composer 安装命令:

composer require kbariotis/documer

包简介

Bayes algorithm implementation in PHP for auto document classification.

README 文档

README

Bayes algorithm implementation in PHP for auto document classification.

Concept

every document has key words e.g. Margaret Thatcher

every document has a label e.g. Politics

Suppose, that in every document there are key words all starting with an uppercase letter. We store these words in our DB end every time we need to guess a document against a particular label, we use Bayes algorithm.

Let's clear that out:

Training:

First, we tokenize the document and keep only our key words (All words starting with an uppercase letter) in an array. We store that array in our DB.

Guessing:

This is very simple. Again, we parse the document we want to be classified and create an array with the key words. Here is the pseudo code:

for every label in DB
	for every key word in document
		P(label/word) = P(word/label)P(label) /	( P(word/label)P(label) + (1 - P(word/label))(1 - P(label)) )

Usage

Install through composer

"require": {
    "kbariotis/documer": "dev-master"
  },

Instantiate

Pass a Storage Adapter object to the Documer Constructor.

$documer = new Documer\Documer(new \Documer\Storage\Memory());

Train

$documer->train('politics', 'This is text about Politics and more');
$documer->train('philosophy', 'Socrates is an ancent Greek philosopher');
$documer->train('athletic', 'Have no idea about athletics. Sorry.');
$documer->train('athletic', 'Not a clue.');
$documer->train('athletic', 'It is just not my thing.');

Guess

$scores = $documer->guess('What do we know about Socrates?');

$scores will hold an array with all labels of your system and the posibbility which the document will belong to each label.

Storage Adapters Implement Documer\Storage\Adapter to create your own Storage Adapter.

统计信息

  • 总下载量: 180
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 78
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 77
  • Watchers: 7
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-12-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固