Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Changed the constructor signature so that the text sample is not requ…

…ired.
  • Loading branch information...
commit bf6220870b63e1d2a6fe4299a9db57a7c8cc6adf 1 parent 9165c6b
Ben Waine authored
3  BayesPHP/Sample.php
View
@@ -61,9 +61,8 @@ class Sample
* @param Stemer $stemer A stemer used to stem the words in each of the text samples.
* @param WordCounter $counter A word counter used to count words in text samples.
*/
- public function __construct($sample, Stemer $stemer, WordCounter $counter)
+ public function __construct(Stemer $stemer, WordCounter $counter)
{
- $this->setSample($sample);
$this->stemer = $stemer;
$this->counter = $counter;
}
7 Tests/BayesPHP/SampleTest.php
View
@@ -21,11 +21,10 @@ class SampleTest extends \PHPUnit_Framework_TestCase
*/
protected function setUp()
{
- $sample = array('p' =>array(), 'n' => array());
$stemer = m::mock('\BayesPHP\Stemer');
$counter = m::mock('\BayesPHP\WordCounter');
- $this->object = new Sample($sample, $stemer, $counter);
+ $this->object = new Sample($stemer, $counter);
}
/**
@@ -89,8 +88,8 @@ public function testProcessProducesCorrectOutcomes()
$stemer = m::mock('\BayesPHP\Stemer');
$stemer->shouldReceive('process')->times(8);
- $sampler = new Sample($sample, $stemer, $wordCounter);
-
+ $sampler = new Sample($stemer, $wordCounter);
+ $sampler->setSample($sample);
$result = $sampler->process();
$this->assertType('\BayesPHP\Sample\Result', $result);
4 examples/Example.php
View
@@ -73,8 +73,8 @@
// Suggestion: use a common word list and always remove the subject word.
$stemer->setWordBlacklist(array('fox', 'i', 'a', 'if'));
-$sample = new BayesPHP\Sample($textSample, $stemer, $wordCounter);
-
+$sample = new BayesPHP\Sample($stemer, $wordCounter);
+$sample->setSample($textSample);
// Process the sample and produce a result object.
$result = $sample->process();
Please sign in to comment.
Something went wrong with that request. Please try again.