Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding basic usage to README.md

  • Loading branch information...
commit e817280a3081cd48c7cc031ab7743a694399602e 1 parent 2dd7ac7
a_musing_moose authored
View
36 README.md
@@ -17,5 +17,39 @@ Wotsit is designed to be packaged as a phar file. To create the package run:
This will build run all tests, create documentation (in the /docs folder) and creates the Wotsit.phar file
## Usage
-See documentation which can be build by running:
+
+### Basic Usage
+
+With a pre-trained classifier:
+ require 'Wotsit.phar';
+ //initialise storage object with previously learned data
+ $storage = new wotsit_storage_Dbm('data.db');
+
+ $extractor = new wotsit_feature_WordExtractor();
+ $classfier = new wotsit_classifier_NaiveBayesian($extractor, $storage);
+
+ //classify the passed in text
+ $category = $classfier->classify($someText);
+
+Training:
+ require 'Wotsit.phar';
+ $storage = new wotsit_storage_Dbm('new.db');
+
+ $extractor = new wotsit_feature_WordExtractor(); //NB: You can also pass in a stemmer if you desire
+ $classfier = new wotsit_classifier_NaiveBayesian($extractor, $storage);
+
+ $goodData = array(); //should be examples of documents which are in the category 'good'
+ $badData = array(); //should be examples of documents which are in the category 'bad'
+
+ //Adding examples of 'good' data
+ foreach ($goodData as $goodDatum) {
+ $classfier->train($goodDatum, 'good');
+ }
+
+ //adding examples of 'bad' data
+ foreach ($badData as $badDatum) {
+ $classfier->train($badDatum, 'bad');
+ }
+
+For more informtaion see documentation which can be build by running:
phing api-docs
View
2  src/tutorials/wotsit/examples/preTrained.php
@@ -1,6 +1,6 @@
<?php
//initialise storage object with previously learned data
-$storage = new wotsit_storage_Sqlite('data.db');
+$storage = new wotsit_storage_Dbm('data.db');
$extractor = new wotsit_feature_WordExtractor();
$classfier = new wotsit_classifier_NaiveBayesian($extractor, $storage);
View
2  src/tutorials/wotsit/examples/training.php
@@ -1,6 +1,6 @@
<?php
//initialise storage object with previously learned data
-$storage = new wotsit_storage_Sqlite('new.db');
+$storage = new wotsit_storage_Dbm('new.db');
$extractor = new wotsit_feature_WordExtractor(); //NB: You can also pass in a stemmer if you desire
$classfier = new wotsit_classifier_NaiveBayesian($extractor, $storage);
Please sign in to comment.
Something went wrong with that request. Please try again.