PHPackages                             kbariotis/documer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kbariotis/documer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kbariotis/documer
=================

Bayes algorithm implementation in PHP for auto document classification.

0.2.3(11y ago)771805[1 issues](https://github.com/kbariotis/documer/issues)MITPHP

Since Dec 18Pushed 8y ago7 watchersCompare

[ Source](https://github.com/kbariotis/documer)[ Packagist](https://packagist.org/packages/kbariotis/documer)[ Docs](http://github.com/kbariotis/documer)[ RSS](/packages/kbariotis-documer/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (6)Used By (0)

Documer
=======

[](#documer)

Bayes algorithm implementation in PHP for auto document classification.

Concept
-------

[](#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
-----

[](#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](src/Storage/Adapter.php) to create your own Storage Adapter.

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

5

Last Release

4199d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/72617910?v=4)[stakisko](/maintainers/stakisko)[@stakisko](https://github.com/stakisko)

---

Top Contributors

[![kbariotis](https://avatars.githubusercontent.com/u/605742?v=4)](https://github.com/kbariotis "kbariotis (93 commits)")[![cryptoBOOOOM](https://avatars.githubusercontent.com/u/3755177?v=4)](https://github.com/cryptoBOOOOM "cryptoBOOOOM (1 commits)")

---

Tags

bayes-algorithmphpclassificationmachine learningbayes

### Embed Badge

![Health badge](/badges/kbariotis-documer/health.svg)

```
[![Health](https://phpackages.com/badges/kbariotis-documer/health.svg)](https://phpackages.com/packages/kbariotis-documer)
```

###  Alternatives

[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.5M28](/packages/rubix-ml)[nlp-tools/nlp-tools

NlpTools is a set of php 5.3+ classes for beginner to semi advanced natural language processing work.

764664.2k5](/packages/nlp-tools-nlp-tools)[codewithkyrian/transformers

State-of-the-art Machine Learning for PHP. Run Transformers in PHP

757254.8k7](/packages/codewithkyrian-transformers)[php-ai/php-ml

PHP-ML - Machine Learning library for PHP

1061.8M13](/packages/php-ai-php-ml)[niiknow/bayes

a machine learning lib

6954.1k](/packages/niiknow-bayes)[davmixcool/php-sentiment-analyzer

PHP Sentiment Analyzer is a lexicon and rule-based sentiment analysis tool that is used to understand sentiments in a sentence using VADER (Valence Aware Dictionary and sentiment Reasoner).

134167.1k1](/packages/davmixcool-php-sentiment-analyzer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
