Guest User

Untitled

a guest
Jan 17th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.67 KB | None | 0 0
  1. <?php
  2.  /*
  3. ===========================================================
  4.  Created by Nevian
  5. -----------------------------------------------------------
  6.  e-mail: neavian@gmail.com;
  7. -----------------------------------------------------------
  8.  Copyright (c) Strzhegovsky Gleb
  9. ===========================================================
  10.  Code is protected by copyrights
  11. ===========================================================
  12.  File: bred.php
  13. -----------------------------------------------------------
  14.  Target: Words fun generator v 1.1
  15. ===========================================================
  16. */
  17.  
  18. error_reporting(E^ALL);
  19. mb_internal_encoding('UTF-8');
  20.  
  21. $input   = $_POST['text'];
  22. $options = intval($_POST['options']);
  23. $vonny   = intval($_POST['vonny']);
  24.  
  25. $symbols = array('!', '?', '.', ',');
  26. $sentences = array( '1' => 'adv, union adverb!',
  27.                     '2' => 'union sdv union noun?',
  28.                     '3' => 'union union noun union union noun?',
  29.                     '4' => 'adv union noun adverb noun'
  30.                     );
  31.  
  32. $input = str_replace($symbols, '', $input);
  33. $text = explode(' ',$input);
  34.  
  35. $union     = array(); // Союз
  36. $verb      = array(); // Глагол
  37. $adverb    = array(); // Наречие
  38. $adjective = array(); // Прилагательное
  39. $noun      = array(); // Существительное
  40.  
  41. if (count($text) > 7) {
  42.  
  43.     for ($i=0;$i<count($text);$i++) {
  44.         if (strlen($text[$i]) <= 3) {
  45.             $union[] = $text[$i];
  46.         } elseif (preg_match('/(ось|ел|ться|тся|или|лась|ит|ть|ет|али|шь|шься|аем|лся|лись|еем|ели)$/i', $text[$i]) && strlen($text[$i]) > 3) {
  47.             $verb[] = $text[$i];
  48.         } elseif (preg_match('/(ро|нь|но|ко)$/i', $text[$i]) && strlen($text[$i]) > 3) {
  49.             $adverb[] = $text[$i];
  50.         } elseif (preg_match('/(ую|ая|ый|ое|ые|ой)$/i', $text[$i]) && strlen($text[$i]) > 3) {
  51.             $adjective[] = $text[$i];
  52.         } else {
  53.             $noun[] = $text[$i];
  54.         }
  55.     }
  56.  
  57.     function vonny($text) {
  58.         $input = explode(' ', $text);
  59.         $words = count($input);
  60.         $letters = array("а", "ё", "и", "ю", "о", "е");
  61.  
  62.         for ($i=0;$i<$words;$i++) {
  63.             $r_word = mt_rand(1,6);
  64.             $input = str_replace($letters[$r_word], '', $input);
  65.         }
  66.         $input = implode(' ', $input);
  67.    
  68.         return stripslashes($input);
  69.     }
  70.  
  71.     function register($str='',$to='lower') {
  72.         $lower = array('а','б','в','г','д','е','ё','ж','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','х','ц','ч','ш','щ','ь','ы','ъ','э','ю','я');
  73.         $upper = array('А','Б','В','Г','Д','Е','Ё','Ж','З','И','Й','К','Л','М','Н','О','П','Р','С','Т','У','Ф','Х','Ц','Ч','Ш','Щ','Ь','Ы','Ъ','Э','Ю','Я');
  74.  
  75.         if ($to == 'lower') {
  76.             $pat = &$upper;
  77.             $rep = &$lower;
  78.         } elseif($to == 'upper') {
  79.             $pat = &$lower;
  80.             $rep = &$upper;
  81.         }
  82.  
  83.         for($n=0;$n<sizeof($pat);++$n) {
  84.             $str = preg_replace("/".$pat[$n]."/",$rep[$n],$str);
  85.         }
  86.  
  87.         return $str;
  88.     }
  89.  
  90.     function orf($text) {
  91.         $text = preg_replace_callback('~(!|\?|\.)(\s*)([a-zа-яё]{1})~isuU', function($match){
  92.             return $match[1].$match[2].mb_strtoupper($match[3], 'utf-8');
  93.         }, $text);
  94.  
  95.     return $text;
  96.     }
  97. }
  98.  
  99.  
  100. //Как идея:
  101. function bredgen($text) {
  102.     //Тут мы считаем колво слово и каким-то хуем составляем предложения по конструкциям из массива, типа так
  103.     $konstrukciya        = $sentences[mt_rand(0,count($sentences))];
  104.     $novoe_predlojenie[] = str_replace($konstrukciya, $text[mt_rand(0,count($text))], $text);
  105.     //Код очень сырой, но идею я думаю, ты поймйёшь) И вот с этой функцией ай нид ёр хелп)
  106. }
  107.  
  108. ?>
Add Comment
Please, Sign In to add comment