| Total Complexity | 11 |
| Total Lines | 72 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class TfIdfTransformer implements Transformer |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var array |
||
| 13 | */ |
||
| 14 | private $idf = []; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * The term counts. |
||
| 18 | * |
||
| 19 | * @var array |
||
| 20 | */ |
||
| 21 | private $termCounts = []; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * The minimum accepted term frequency. |
||
| 25 | * |
||
| 26 | * @var int |
||
| 27 | */ |
||
| 28 | private $minTf; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * The minimum accepted IDF value. |
||
| 32 | * |
||
| 33 | * @var float |
||
| 34 | */ |
||
| 35 | private $minIdf; |
||
| 36 | |||
| 37 | public function __construct(array $samples = [], int $minTf = 0, float $minIdf = 0.0) |
||
| 38 | { |
||
| 39 | if (count($samples) > 0) { |
||
| 40 | $this->fit($samples); |
||
| 41 | } |
||
| 42 | $this->minTf = $minTf; |
||
| 43 | $this->minIdf = $minIdf; |
||
| 44 | } |
||
| 45 | |||
| 46 | public function fit(array $samples, ?array $targets = null): void |
||
| 66 | ); |
||
| 67 | } |
||
| 68 | |||
| 69 | public function transform(array &$samples, ?array &$targets = null): void |
||
| 84 |