Browse files

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

…ired.
  • Loading branch information...
1 parent 9165c6b commit bf6220870b63e1d2a6fe4299a9db57a7c8cc6adf Ben Waine committed Jul 10, 2011
Showing with 6 additions and 8 deletions.
  1. +1 −2 BayesPHP/Sample.php
  2. +3 −4 Tests/BayesPHP/SampleTest.php
  3. +2 −2 examples/Example.php
View
3 BayesPHP/Sample.php
@@ -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;
}
View
7 Tests/BayesPHP/SampleTest.php
@@ -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);
View
4 examples/Example.php
@@ -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();

0 comments on commit bf62208

Please sign in to comment.