Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- error_reporting(E_ALL | E_STRICT);
- ini_set('display_errors', TRUE);
- ini_set('display_startup_errors', TRUE);
- header('Content-type: text/html; charset=windows-1251');
- $g1 = microtime(true);
- $url = "http://{$_SERVER['HTTP_HOST']}/p/"; // !!!!!!!!!!!!!!!!!
- $dir = 'p'; // !!!!!!!!!!!!!!!!!
- $files0 = array();
- $files1 = scandir($dir);
- unset($files1[0]);
- unset($files1[1]);
- $result = array_merge($files0, $files1);
- //print_r($result);
- $countfiles = count($files1);
- $numfiles = $countfiles-1;
- echo "Файлов (эл-в массива): $numfiles <br><br><br>\n\n\n";
- //$i = 0;
- $AlphPred = array();
- for ($i = 0; $i < 20000; $i++) {
- $filename = "$dir/$result[$i]";
- $handle = fopen("$filename", "r");
- $contents = fread($handle, filesize($filename));
- //echo "$contents";
- ## !!! Для смены начала предложения заменить фразу "Для\sтого" !!!
- $jj = preg_match_all("/\.\s{1,}Для\sтого[а-яёА-ЯЁa-zA-Z\s;:,-]{1,}\./sm", $contents, $result2);
- //$jj = preg_match_all("/не\sочень-то[а-яёА-ЯЁa-zA-Z\s;:,-]{1,}\./sm", $contents, $result2);
- if(isset($result2[0][0])){
- $tc = count($result2[0]);
- //echo "$tc";
- for ($t = 0; $t < $tc; $t++) {
- $result2[0][$t] = preg_replace('/^\.\s{1,}/ism', "", $result2[0][$t]);
- $AlphPred[] = $result2[0][$t];
- }
- /*
- echo "<pre>";
- //echo "jj = $jj";
- var_dump($AlphPred);
- echo "</pre>";
- */
- }
- }
- $AlphPred = array_unique($AlphPred);
- sort($AlphPred);
- $CountAlphPred = count($AlphPred);
- for ($t = 0; $t < $CountAlphPred; $t++) {
- echo "{$AlphPred[$t]}<br>";
- }
- $g2 = microtime(true);
- $g3 = $g2 - $g1; // время генерации
- echo "\n<br>Время: ". $g3 ."<br>\n";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement