예제 #1
0
}
$lineCount = 1;
$inputType = 1;
echo "Enter inputtype:" . PHP_EOL . "1)integer" . PHP_EOL . "2)character" . PHP_EOL;
$handle = fopen("php://stdin", "r");
$inputType = (int) fgets($handle);
if ($inputType <= 0 || $inputType > 2) {
    echo "Enter valid no!" . PHP_EOL;
    exit;
}
$test = new Tokenizer();
while (1) {
    echo "Enter line {$lineCount}:" . PHP_EOL;
    $handle = fopen("php://stdin", "r");
    if ($inputType == 1) {
        $line = (int) fgets($handle);
    } else {
        $line = fgets($handle);
    }
    //adds the line to tokenizer and get the token strength
    $tokenStrength = $test->addline($line)->getRepeatedTokenStrength(0, 1);
    if ($tokenStrength) {
        var_dump($tokenStrength);
        exit;
    }
    if (trim($line) == 'q') {
        echo "ABORTING!\n";
        exit;
    }
    $lineCount++;
}