Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
@@ -61,9 +61,8 @@ class Sample
61 61 * @param Stemer $stemer A stemer used to stem the words in each of the text samples.
62 62 * @param WordCounter $counter A word counter used to count words in text samples.
63 63 */
64   - public function __construct($sample, Stemer $stemer, WordCounter $counter)
  64 + public function __construct(Stemer $stemer, WordCounter $counter)
65 65 {
66   - $this->setSample($sample);
67 66 $this->stemer = $stemer;
68 67 $this->counter = $counter;
69 68 }
7 Tests/BayesPHP/SampleTest.php
@@ -21,11 +21,10 @@ class SampleTest extends \PHPUnit_Framework_TestCase
21 21 */
22 22 protected function setUp()
23 23 {
24   - $sample = array('p' =>array(), 'n' => array());
25 24 $stemer = m::mock('\BayesPHP\Stemer');
26 25 $counter = m::mock('\BayesPHP\WordCounter');
27 26
28   - $this->object = new Sample($sample, $stemer, $counter);
  27 + $this->object = new Sample($stemer, $counter);
29 28 }
30 29
31 30 /**
@@ -89,8 +88,8 @@ public function testProcessProducesCorrectOutcomes()
89 88 $stemer = m::mock('\BayesPHP\Stemer');
90 89 $stemer->shouldReceive('process')->times(8);
91 90
92   - $sampler = new Sample($sample, $stemer, $wordCounter);
93   -
  91 + $sampler = new Sample($stemer, $wordCounter);
  92 + $sampler->setSample($sample);
94 93 $result = $sampler->process();
95 94
96 95 $this->assertType('\BayesPHP\Sample\Result', $result);
4 examples/Example.php
@@ -73,8 +73,8 @@
73 73 // Suggestion: use a common word list and always remove the subject word.
74 74 $stemer->setWordBlacklist(array('fox', 'i', 'a', 'if'));
75 75
76   -$sample = new BayesPHP\Sample($textSample, $stemer, $wordCounter);
77   -
  76 +$sample = new BayesPHP\Sample($stemer, $wordCounter);
  77 +$sample->setSample($textSample);
78 78
79 79 // Process the sample and produce a result object.
80 80 $result = $sample->process();

0 comments on commit bf62208

Please sign in to comment.
Something went wrong with that request. Please try again.