public function testFeatureCount() { for ($i = 1; $i < 4; $i++) { $this->storage->increaseFeatureCount('testFeature'); $this->assertEquals($i, $this->storage->getFeatureCount('testFeature')); } $this->storage->increaseFeatureCount('testFeature2'); $this->assertEquals(1, $this->storage->getFeatureCount('testFeature2')); }
/** * Train classifier categorize given features to given category. * * @param string $category Category of features. * @param array $features Features of category. * * @return void */ public function learn($category, array $features) { $this->storage->increaseDocumentsCount(); $this->storage->increaseCategoryDocumentsCount($category); $uniqueFeatures = array_unique($features); foreach ($uniqueFeatures as $uniqueFeature) { $this->storage->increaseFeatureDocumentsCountInCategory($category, $uniqueFeature); } foreach ($features as $feature) { $this->storage->increaseFeaturesCount(); $this->storage->increaseFeatureCount($feature); $this->storage->increaseCategoryFeaturesCount($category); $this->storage->increaseFeatureCountInCategory($category, $feature); } }