true; $extensions = [ ', ehrlich gesagt', ', wenn ich so darüber nachdenke', ', glaub mir', ', kann ich dir sagen', ', das ist klar', ', das kann ich dir versichern', ', ohne Witz', ', ist doch logisch', ', oder etwa nicht' ]; $text = preg_replace('/(\.\s+)(?=[A-ZÄÖÜ])/u', $extensions[array_rand($extensions)] . '$1', $text, 1); } // Veraltete oder regionale Ausdrücke einfügen if (p_chaos_decide($chaos_rate / 4, 'expressions', $previous_changes, $anti_pattern)) { $current_changes['expressions'] = true; $expressions = [ 'prima' => ['super', 'toll', 'klasse', 'spitze', 'mega'], 'schlecht' => ['mies', 'mau', 'bescheiden', 'doof', 'übel'], 'interessant' => ['spannend', 'faszinierend', 'bemerkenswert', 'kurios', 'eigenartig'], 'gut' => ['knorke', 'dufte', 'töfte', 'fett', 'geil'], 'sehr' => ['echt', 'total', 'voll', 'komplett', 'absolut'] ]; foreach ($expressions as $standard => $alternatives) { if (stripos($text, $standard) !== false && mt_rand(1, 3) == 1) { $text = str_ireplace( $standard, $alternatives[array_rand($alternatives)], $text, 1 ); break; // Nur eine Ersetzung pro Durchlauf } } } // Füge aktuelle Änderungen zum Änderungsverlauf hinzu array_unshift($previous_changes, $current_changes); // Begrenze die Größe des Änderungsverlaufs if (count($previous_changes) > 10) { array_pop($previous_changes); } return $text; } /** * Hauptfunktion zur Textverarbeitung */ function p_replace_text($text, $chaos_rate = 30, $text_manipulation = true, $anti_pattern = true, $dynamic_chaos = true, &$previous_changes = [], &$sentence_info = []) { if ($chaos_rate == 0 || empty($text) || !is_singular()) return $text; global $post; $has_changes = false; $protected_content = []; $tag_counter = 0; // GESCHÜTZTE INHALTE: Abkürzungen, HTML-Tags, Überschriften, usw. $abbr_list = [ 'Dr.', 'z.B.', 'usw.', 'etc.', 'ca.', 'Nr.', 'GmbH', 'AG', 'Co.', 'KG', 'Ltd.', 'Tel.', 'Fax.', 'St.', 'bzw.', 'd.h.', 'ggf.', 'i.d.R.', 'u.a.', 'u.U.', 'v.a.', 'vgl.', 'vs.', 'inkl.', 'exkl.', 'max.', 'min.', 'orig.', 'zzt.' ]; // Schutz von HTML-Tags $text = preg_replace_callback('/<[^>]*>/', function($m) use (&$protected_content, &$tag_counter) { $placeholder = "___HTML_TAG_{$tag_counter}___"; $protected_content[$placeholder] = $m[0]; $tag_counter++; return $placeholder; }, $text); // Schutz von Überschriften (h1-h6) $text = preg_replace_callback('/]*>.*?<\/h[1-6]>/si', function($m) use (&$protected_content, &$tag_counter) { $placeholder = "___HEADING_{$tag_counter}___"; $protected_content[$placeholder] = $m[0]; $tag_counter++; return $placeholder; }, $text); // Schutz von Abkürzungen foreach ($abbr_list as $abbr) { $pattern = '/\b' . preg_quote(rtrim($abbr, '.'), '/') . '\.?\b/u'; $text = preg_replace_callback($pattern, function($m) use (&$protected_content, &$tag_counter) { $placeholder = "___ABBR_{$tag_counter}___"; $protected_content[$placeholder] = $m[0]; $tag_counter++; return $placeholder; }, $text); } // Schutz von URLs $text = preg_replace_callback('/https?:\/\/[^\s]+/', function($m) use (&$protected_content, &$tag_counter) { $placeholder = "___URL_{$tag_counter}___"; $protected_content[$placeholder] = $m[0]; $tag_counter++; return $placeholder; }, $text); // Schutz von Zahlenformaten $text = preg_replace_callback('/\b\d+[.,]\d+\b/', function($m) use (&$protected_content, &$tag_counter) { $placeholder = "___NUMBER_{$tag_counter}___"; $protected_content[$placeholder] = $m[0]; $tag_counter++; return $placeholder; }, $text); // Schutz von Emoji $text = preg_replace_callback('/[\x{1F600}-\x{1F64F}]/u', function($m) use (&$protected_content, &$tag_counter) { $placeholder = "___EMOJI_{$tag_counter}___"; $protected_content[$placeholder] = $m[0]; $tag_counter++; return $placeholder; }, $text); // Schutz von Hashtags $text = preg_replace_callback('/#[a-zA-Z0-9_äöüÄÖÜß]+/', function($m) use (&$protected_content, &$tag_counter) { $placeholder = "___HASHTAG_{$tag_counter}___"; $protected_content[$placeholder] = $m[0]; $tag_counter++; return $placeholder; }, $text); // Statistik initialisieren $stats = [ 'dot_total' => 0, 'dot_replaced' => 0, 'comma_total' => 0, 'comma_replaced' => 0, 'comma_protected' => 0, 'question_total' => 0, 'question_modified' => 0, 'exclamation_total' => 0, 'exclamation_modified' => 0, 'special_total' => 0, 'special_cleaned' => 0, 'conjunction_total' => 0, 'conjunction_removed' => 0, 'spacing_total' => 0, 'spacing_modified' => 0, 'typos_total' => 0, 'typos_applied' => 0, 'quote_total' => 0, 'quote_applied' => 0, 'avg_chaos_rate' => 0, 'chaos_rates' => [], 'effective_chaos_rate' => 0 ]; // Token zählen preg_match_all('/\.(?![\d])/', $text, $dots); preg_match_all('/,(?![\d])/', $text, $commas); preg_match_all('/,\s+(und|oder|aber)\b/i', $text, $conjunctions); preg_match_all('/([[:punct:]])\\1{2,}/', $text, $duplicates); preg_match_all('/\?/', $text, $questions); preg_match_all('/!/', $text, $exclamations); preg_match_all('/ \./', $text, $spacing); $stats['dot_total'] = count($dots[0]); $stats['comma_total'] = count($commas[0]); $stats['conjunction_total'] = count($conjunctions[0]); $stats['special_total'] = count($duplicates[0]); $stats['question_total'] = count($questions[0]); $stats['exclamation_total'] = count($exclamations[0]); $stats['spacing_total'] = count($spacing[0]); // Sätze und Absätze identifizieren für kontextbasierte Entscheidungen $paragraphs = preg_split('/\n\s*\n|\r\n\s*\r\n|\r\s*\r/', $text); $paragraph_index = 0; foreach ($paragraphs as $paragraph) { // Sätze innerhalb des Absatzes identifizieren $sentences = preg_split('/(?<=[.!?])\s+(?=[A-ZÄÖÜ])/u', $paragraph); $sentences_count = count($sentences); for ($i = 0; $i < $sentences_count; $i++) { $sentence = $sentences[$i]; $sentence_length = str_word_count($sentence); $sentence_complexity = substr_count($sentence, ','); // Speichere Informationen zu diesem Satz $sentence_info[] = [ 'paragraph' => $paragraph_index, 'sentence' => $i, 'length' => $sentence_length, 'complexity' => $sentence_complexity ]; // Berechne dynamische Chaos-Rate für diesen Satz $current_chaos_rate = $chaos_rate; if ($dynamic_chaos) { $current_chaos_rate = p_get_dynamic_chaos_rate( $sentence_length, $i, $sentences_count, $chaos_rate, $sentence_complexity ); $stats['chaos_rates'][] = $current_chaos_rate; } } $paragraph_index++; } // Berechne durchschnittliche Chaos-Rate if ($dynamic_chaos && !empty($stats['chaos_rates'])) { $stats['avg_chaos_rate'] = array_sum($stats['chaos_rates']) / count($stats['chaos_rates']); } else { $stats['avg_chaos_rate'] = $chaos_rate; } // Wörter für potenzielle Tippfehler zählen $typo_candidates = [ 'und', 'ist', 'der', 'die', 'das', 'mit', 'für', 'von', 'den', 'zu', 'wir', 'sie', 'sich', 'auch', 'eine', 'einen', 'einem', 'eines', 'einer', 'kann', 'soll', 'wird', 'wurde', 'haben', 'hatte', 'gibt', 'zum', 'zur' ]; $stats['typos_total'] = 0; foreach ($typo_candidates as $word) { $pattern = '/\b' . preg_quote($word, '/') . '\b/i'; preg_match_all($pattern, $text, $matches); $stats['typos_total'] += count($matches[0]); } // Wörter zählen, die für Anführungszeichen in Frage kommen preg_match_all('/\b[a-zA-ZäöüÄÖÜß]{4,}\b/u', $text, $potential_quote_words); $stats['quote_total'] = count($potential_quote_words[0]); // Regel 1: Punkte ersetzen $text = preg_replace_callback('/\.(?![\d])/', function($m) use ($chaos_rate, &$stats, &$has_changes, $dynamic_chaos, $sentence_info, &$previous_changes, $anti_pattern) { $current_chaos = $dynamic_chaos && !empty($stats['chaos_rates']) ? $stats['chaos_rates'][mt_rand(0, count($stats['chaos_rates'])-1)] : $chaos_rate; if (p_chaos_decide($current_chaos, 'dot_replace', $previous_changes, $anti_pattern)) { $stats['dot_replaced']++; $has_changes = true; // Verschiedene Punktersetzungen mit unterschiedlichen Wahrscheinlichkeiten $replacements = []; if (!isset($previous_changes[0]['dot_replace_dots']) || !$previous_changes[0]['dot_replace_dots']) { $replacements[] = '...'; } if (!isset($previous_changes[0]['dot_replace_dash']) || !$previous_changes[0]['dot_replace_dash']) { $replacements[] = '-'; } if (!isset($previous_changes[0]['dot_replace_colon']) || !$previous_changes[0]['dot_replace_colon']) { $replacements[] = ':'; } if (empty($replacements)) { $replacements = ['...', '-', ':']; } $replacement = $replacements[array_rand($replacements)]; // Speichere die Art der Ersetzung für Anti-Pattern $change_type = 'dot_replace_' . ($replacement == '...' ? 'dots' : ($replacement == '-' ? 'dash' : 'colon')); array_unshift($previous_changes, [$change_type => true]); return $replacement; } return $m[0]; }, $text); // Regel 2: Kommas ersetzen $text = preg_replace_callback('/,(?![\d])/', function($m) use ($chaos_rate, &$stats, &$has_changes, $dynamic_chaos, $sentence_info, &$previous_changes, $anti_pattern) { $current_chaos = $dynamic_chaos && !empty($stats['chaos_rates']) ? $stats['chaos_rates'][mt_rand(0, count($stats['chaos_rates'])-1)] : $chaos_rate; if (p_chaos_decide($current_chaos, 'comma_replace', $previous_changes, $anti_pattern)) { $stats['comma_replaced']++; $has_changes = true; // Verschiedene Kommaersetzungen $replacements = []; if (!isset($previous_changes[0]['comma_replace_semi']) || !$previous_changes[0]['comma_replace_semi']) { $replacements[] = ';'; } if (!isset($previous_changes[0]['comma_replace_dash']) || !$previous_changes[0]['comma_replace_dash']) { $replacements[] = ' -'; } if (mt_rand(1, 10) <= 3) { // Seltenere Ersetzungen $replacements[] = ' ...'; } if (empty($replacements)) { $replacements = [';', ' -']; } $replacement = $replacements[array_rand($replacements)]; // Speichere die Art der Ersetzung für Anti-Pattern $change_type = 'comma_replace_' . ($replacement == ';' ? 'semi' : ($replacement == ' -' ? 'dash' : 'dots')); array_unshift($previous_changes, [$change_type => true]); return $replacement; } return $m[0]; }, $text); // Regel 4: Fragezeichen + Anführung $text = preg_replace_callback('/\b(\w+)\s*\?/', function($m) use ($chaos_rate, &$stats, &$has_changes, $dynamic_chaos, $sentence_info, &$previous_changes, $anti_pattern) { $current_chaos = $dynamic_chaos && !empty($stats['chaos_rates']) ? $stats['chaos_rates'][mt_rand(0, count($stats['chaos_rates'])-1)] : $chaos_rate; if (p_chaos_decide($current_chaos, 'question_modify', $previous_changes, $anti_pattern)) { $stats['question_modified']++; $has_changes = true; // Verschiedene Anführungszeichentypen $quote_type = p_get_random_quote_type(); $close_quote = ($quote_type == '"' ? '"' : ($quote_type == '„' ? '"' : ($quote_type == '‚' ? ''' : $quote_type))); // Doppelte oder dreifache Fragezeichen mit geringer Wahrscheinlichkeit $question_mark = mt_rand(1, 10) <= 2 ? (mt_rand(1, 3) == 1 ? '???' : '??') : '?'; // Speichere Änderung für Anti-Pattern array_unshift($previous_changes, ['question_modify' => true]); return $quote_type . $m[1] . $close_quote . $question_mark; } return $m[0]; }, $text); // Regel 5: Ausrufezeichen + Anführung $text = preg_replace_callback('/\b(\w+)\s*!/', function($m) use ($chaos_rate, &$stats, &$has_changes, $dynamic_chaos, $sentence_info, &$previous_changes, $anti_pattern) { $current_chaos = $dynamic_chaos && !empty($stats['chaos_rates']) ? $stats['chaos_rates'][mt_rand(0, count($stats['chaos_rates'])-1)] : $chaos_rate; if (p_chaos_decide($current_chaos, 'exclamation_modify', $previous_changes, $anti_pattern)) { $stats['exclamation_modified']++; $has_changes = true; // Verschiedene Anführungszeichentypen $quote_type = p_get_random_quote_type(); $close_quote = ($quote_type == '"' ? '"' : ($quote_type == '„' ? '"' : ($quote_type == '‚' ? ''' : $quote_type))); // Doppelte oder dreifache Ausrufezeichen mit geringer Wahrscheinlichkeit $exclamation_mark = mt_rand(1, 10) <= 2 ? (mt_rand(1, 3) == 1 ? '!!!' : '!!') : '!'; // Speichere Änderung für Anti-Pattern array_unshift($previous_changes, ['exclamation_modify' => true]); return $quote_type . $m[1] . $close_quote . $exclamation_mark; } return $m[0]; }, $text); // Regel 9: Spezialregeln für Absatzanfang $text = preg_replace_callback('/(

|\n\n)(\w+)/', function($m) use ($chaos_rate, &$stats, &$has_changes, $dynamic_chaos, $sentence_info, &$previous_changes, $anti_pattern) { $current_chaos = $dynamic_chaos ? mt_rand(max(5, $chaos_rate - 10), min(95, $chaos_rate + 10)) : $chaos_rate; if (p_chaos_decide($current_chaos, 'paragraph_start', $previous_changes, $anti_pattern)) { $has_changes = true; // Verschiedene Absatzanfänge $prefixes = [ 'Übrigens: ', 'Nebenbei: ', 'Apropos: ', 'Ehrlich gesagt, ', 'Also, ', 'Tja, ', 'Nun, ', 'Okay, ', 'Hm, ', 'Weißt du, ', 'Ich meine, ', 'Natürlich, ', 'Eigentlich, ', 'Erstaunlicherweise, ', 'Interessanterweise, ' ]; // Vermeidung von wiederholten Präfixen $used_prefixes = []; foreach ($previous_changes as $change) { if (isset($change['paragraph_start_prefix'])) { $used_prefixes[] = $change['paragraph_start_prefix']; } } $available_prefixes = array_diff($prefixes, $used_prefixes); if (empty($available_prefixes)) { $available_prefixes = $prefixes; } $prefix = $available_prefixes[array_rand($available_prefixes)]; // Speichere Änderung für Anti-Pattern array_unshift($previous_changes, ['paragraph_start' => true, 'paragraph_start_prefix' => $prefix]); return $m[1] . $prefix . lcfirst($m[2]); } return $m[0]; }, $text); // Regel 10: Komma vor UND/ODER/ABER entfernen $text = preg_replace_callback('/,\s+(und|oder|aber)\b/i', function($m) use ($chaos_rate, &$stats, &$has_changes, $dynamic_chaos, $sentence_info, &$previous_changes, $anti_pattern) { $current_chaos = $dynamic_chaos && !empty($stats['chaos_rates']) ? $stats['chaos_rates'][mt_rand(0, count($stats['chaos_rates'])-1)] : $chaos_rate; if (p_chaos_decide($current_chaos, 'conjunction_comma', $previous_changes, $anti_pattern)) { $stats['conjunction_removed']++; $has_changes = true; // Speichere Änderung für Anti-Pattern array_unshift($previous_changes, ['conjunction_comma' => true]); return ' ' . $m[1]; } return $m[0]; }, $text); // Regel 11: Mehrfach-Sonderzeichen bereinigen oder variieren $text = preg_replace_callback('/([[:punct:]])\\1{2,}/', function($m) use ($chaos_rate, &$stats, &$has_changes, $dynamic_chaos, $sentence_info, &$previous_changes, $anti_pattern) { $current_chaos = $dynamic_chaos && !empty($stats['chaos_rates']) ? $stats['chaos_rates'][mt_rand(0, count($stats['chaos_rates'])-1)] : $chaos_rate; if (p_chaos_decide($current_chaos, 'special_clean', $previous_changes, $anti_pattern)) { // Berechne eine zufällige Anzahl von Wiederholungen (1-3) $repeat = mt_rand(1, 3); $cleaned = str_repeat($m[1], $repeat); $stats['special_cleaned']++; $has_changes = true; // Speichere Änderung für Anti-Pattern array_unshift($previous_changes, ['special_clean' => true]); return $cleaned; } return $m[0]; }, $text); // Regel 13: Leerzeichenvariation nach Punkten $text = preg_replace_callback('/\.\s+/', function($m) use ($chaos_rate, &$stats, &$has_changes, $dynamic_chaos, $sentence_info, &$previous_changes, $anti_pattern) { $current_chaos = $dynamic_chaos && !empty($stats['chaos_rates']) ? $stats['chaos_rates'][mt_rand(0, count($stats['chaos_rates'])-1)] : $chaos_rate; if (p_chaos_decide($current_chaos, 'spacing_modify', $previous_changes, $anti_pattern)) { $stats['spacing_modified']++; $has_changes = true; // Verschiedene Leerzeichenvarianten $space_types = [ str_repeat(' ', mt_rand(1, 3)), // 1-3 normale Leerzeichen " \t", // Leerzeichen + Tab " \n", // Leerzeichen + Zeilenumbruch " " // Doppeltes Leerzeichen ]; $spacing = $space_types[array_rand($space_types)]; // Speichere Änderung für Anti-Pattern array_unshift($previous_changes, ['spacing_modify' => true]); return '.' . $spacing; } return $m[0]; }, $text); // Regel 14: Natürliche Tippfehler einfügen $words = preg_split('/\s+/', $text); $typo_chance = $dynamic_chaos ? max(1, min(5, round($chaos_rate / 10))) : max(1, min(3, round($chaos_rate / 10))); for ($i = 0; $i < count($words); $i++) { $word = $words[$i]; // Überprüfe, ob das Wort für einen Tippfehler geeignet ist $is_candidate = false; foreach ($typo_candidates as $candidate) { if (stripos($word, $candidate) === 0 && strlen($word) >= 3) { $is_candidate = true; break; } } // Wende Tippfehler nur auf geeignete Wörter an if ($is_candidate && $word !== strtoupper($word) && mt_rand(1, 100) <= $typo_chance) { $current_chaos = $dynamic_chaos && !empty($stats['chaos_rates']) ? $stats['chaos_rates'][mt_rand(0, count($stats['chaos_rates'])-1)] : $chaos_rate; if (p_chaos_decide($current_chaos, 'typo', $previous_changes, $anti_pattern)) { $stats['typos_applied']++; $has_changes = true; // Erzeuge einen natürlichen Tippfehler $words[$i] = p_create_natural_typo($word); // Speichere Änderung für Anti-Pattern array_unshift($previous_changes, ['typo' => true]); } } } $text = implode(' ', $words); // Regel 15: Zufällige Anführungszeichen einfügen $text = preg_replace_callback('/\b([a-zA-ZäöüÄÖÜß]{4,})\b/u', function($m) use ($chaos_rate, &$stats, &$has_changes, $dynamic_chaos, $sentence_info, &$previous_changes, $anti_pattern) { // Nicht zu viele Anführungszeichen einfügen if ($stats['quote_applied'] >= min(5, round($stats['quote_total'] * 0.05))) { return $m[0]; } $current_chaos = $dynamic_chaos && !empty($stats['chaos_rates']) ? $stats['chaos_rates'][mt_rand(0, count($stats['chaos_rates'])-1)] : $chaos_rate; if (p_chaos_decide($current_chaos * 0.3, 'quote', $previous_changes, $anti_pattern)) { $stats['quote_applied']++; $has_changes = true; // Verschiedene Anführungszeichentypen $quote_type = p_get_random_quote_type(); $close_quote = ($quote_type == '"' ? '"' : ($quote_type == '„' ? '"' : ($quote_type == '‚' ? ''' : $quote_type))); // Speichere Änderung für Anti-Pattern array_unshift($previous_changes, ['quote' => true]); return $quote_type . $m[1] . $close_quote; } return $m[0]; }, $text, 5); // Begrenze auf 5 Ersetzungen // Geschützte Inhalte wiederherstellen foreach ($protected_content as $placeholder => $original) { $text = str_replace($placeholder, $original, $text); } // Effektive Chaos-Rate berechnen $total_modifiable = $stats['dot_total'] + $stats['comma_total'] + $stats['conjunction_total'] + $stats['special_total'] + $stats['question_total'] + $stats['exclamation_total'] + $stats['spacing_total'] + $stats['typos_total'] + $stats['quote_total']; $modified = $stats['dot_replaced'] + $stats['comma_replaced'] + $stats['conjunction_removed'] + $stats['special_cleaned'] + $stats['question_modified'] + $stats['exclamation_modified'] + $stats['spacing_modified'] + $stats['typos_applied'] + $stats['quote_applied']; $stats['effective_chaos_rate'] = $total_modifiable ? round(($modified / $total_modifiable) * 100) : 0; // Zusätzliche Textmanipulation if ($text_manipulation && $has_changes) { $text = apply_human_text_patterns($text, $stats['avg_chaos_rate'], $previous_changes, $sentence_info, $anti_pattern); } // Nur loggen, wenn Änderung stattgefunden hat if ($has_changes) { p_log_detailed_stats($stats, $chaos_rate, get_the_title()); } return $text; }S
Warning: Cannot modify header information - headers already sent by (output started at /var/customers/webs/Muhsin/muhsin.de/wp-content/plugins/punctuation/punctuation.php:1) in /var/customers/webs/Muhsin/muhsin.de/wp-includes/pluggable.php on line 1435

Warning: Cannot modify header information - headers already sent by (output started at /var/customers/webs/Muhsin/muhsin.de/wp-content/plugins/punctuation/punctuation.php:1) in /var/customers/webs/Muhsin/muhsin.de/wp-includes/pluggable.php on line 1438