Home
DevCentral
Search
Configure Global Search
Log In
Transactions
P23
Change Details
Change Details
Old
New
Diff
#!/usr/bin/env php <?php require 'proper_nouns.php'; class ExtractorCommand { /** * An instance of the proper_nouns class * * @var proper_nouns */ private $extractor; public static function getCommandName() { global $argv; return basename($argv[0]); } public static function usage () { global $argv; echo "Usage: " . self::getCommandName() . " <text file>\n"; } public static function run () { global $argc, $argv; if ($argc < 2) { self::usage(); exit; } $file = $argv[1]; if (!file_exists($file)) { echo self::getCommandName() . ": $file: No such file\n"; exit; } self::printNounsFromFile($file); } public static function printNounsFromFile ($file) { $text = file_get_contents($file); $nouns = self::getNouns($text); foreach ($nouns as $noun) { echo "$noun\n"; } } public static function getNouns ($text) { return (new proper_nouns())->get($text); } } ExtractorCommand::run();
#!/usr/bin/env php <?php require 'proper_nouns.php'; class ExtractorCommand { /** * An instance of the proper_nouns class * * @var proper_nouns */ private $extractor; public static function getCommandName() { global $argv; return basename($argv[0]); } public static function usage () { global $argv; echo "Usage: " . self::getCommandName() . " <text file>\n"; } public static function run () { global $argc, $argv; if ($argc < 2) { self::usage(); exit; } $file = $argv[1]; if (!file_exists($file)) { echo self::getCommandName() . ": $file: No such file\n"; exit; } self::printNounsFromFile($file); } public static function printNounsFromFile ($file) { $text = file_get_contents($file); $nouns = self::getNouns($text); foreach ($nouns as $noun) { echo "$noun\n"; } } public static function getNouns ($text) { return (new proper_nouns())->get($text); } } ExtractorCommand::run();
Continue