Skip to content

Commit

Permalink
reformatting and update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
noogen committed Jul 8, 2019
1 parent d41ab39 commit c002bda
Show file tree
Hide file tree
Showing 4 changed files with 1,772 additions and 131 deletions.
35 changes: 30 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
/node_modules
/public/hot
/public/storage
/storage/*.key
/storage/debugbar
/vendor
/.idea
/.vagrant
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log

.DS_Store
.idea/
vendor/
build/
composer.lock
coverage/
bootstrap/cache/*.php
storage/build/
public/js/parts/*
.env

.docker/data/
!.docker/data/*/*.gitkeep
!.docker/data/*.gitkeep
.docker/logs/
!.docker/logs/*.gitkeep
storage/installed
docker-compose.yml
._*.png
dist.zip
.php*.cache

/.phpintel/
playbook/recipe/downloaded/
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ Teach your classifier what `category` the `text` belongs to. The more you teach

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

### `$classifier->propabilities(text)`

Extract the probabilities for each known category.

### `$classifier->toJson()`

Returns the JSON representation of a classifier.
Expand All @@ -73,5 +77,33 @@ Returns the JSON representation of a classifier.

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

## Stopwords

You can pass in your own tokenizer function in the constructor. Example:

```
// array containing stopwords
$stopwords = array("der", "die", "das", "the");
// escape the stopword array and implode with pipe
$s = '~^\W*('.implode("|", array_map("preg_quote", $stopwords)).')\W+\b|\b\W+(?1)\W*$~i';
$options['tokenizer'] = function($text) use ($s) {
// convert everything to lowercase
$text = mb_strtolower($text);
// remove stop words
$text = preg_replace($s, '', $text);
// split the words
preg_match_all('/[[:alpha:]]+/u', $text, $matches);
// first match list of words
return $matches[0];
};
$classifier = new \niiknow\Bayes($options);
```

## MIT

Loading

0 comments on commit c002bda

Please sign in to comment.