public function testGettysburgTxt() { $texter = new Texter(); $path_to_text = __DIR__ . '/gettysburg.txt'; $sentence = file_get_contents($path_to_text); $results = $texter->analyze_text($sentence); $actual = $results['top']; $expected = array('that' => 13, 'the' => 11, 'we' => 10, 'to' => 8, 'here' => 8); $this->assertEquals($expected, $actual); }
<?php require_once __DIR__ . '/class.texter.php'; require_once __DIR__ . '/helpers.texter.php'; $content = isset($argv[1]) ? @file_get_contents($argv[1]) : file_get_contents("php://stdin"); $content = trim($content); if (empty($content)) { print_help_and_exit(); } $texter = new Texter(); $results = $texter->analyze_text($content); display_results($results);