Финальный заблокированный код

## Финальный заблокированный код: ALEX SYSTEM APP v5.1 (Final Stable)

import refrom collections import Counter
class AlexSystemApp:
    def __init__(self):
        # Строго выверенный список стоп-слов для фильтрации шума
        self.stop_words = {
            'И', 'В', 'ВО', 'НА', 'С', 'СО', 'НЕ', 'ЧТО', 'КАК', 'Я', 'МЫ', 'ЭТО',
            'А', 'НО', 'ИЛИ', 'ДА', 'ЗА', 'К', 'КО', 'У', 'О', 'ОБ', 'ОБО', 'ПО',
            'ИЗ', 'ОТ', 'ДО', 'ДЛЯ', 'ПРИ', 'ПОД', 'ПЕРЕД', 'ТАК', 'ЖЕ', 'БЫ', 'ЛИ'
        }
        # Маркеры кликбейта (ядовитые триггеры)
        self.clickbait_triggers = ['ШОК', 'СРОЧНО', 'ВЫ НЕ ПОВЕРИТЕ', 'СЕНСАЦИЯ', 'ТАЙНА', 'СЕКРЕТНЫЙ', 'ЖЕСТЬ']

    def print_header(self, title):
        print("\n" + "=" * 60)
        print(f"      ALEX: SAVE NEURO ATMOSPHERE | {title}")
        print("=" * 60)

    def _prepare_words(self, text):
        """Внутренний фильтр: предотвращает баг с 'Ё' и гарантирует очистку"""
        words = re.findall(r'\b[А-Яа-яЁё]+\b', text)
        return [w.upper().replace('Ё', 'Е') for w in words]

    # MODULE 1: Лингвистический рентген
    def analyze_text(self, text):
        self.print_header("РЕНТГЕН МЫСЛИ / TEXT ANALYSIS")
        clean_words = self._prepare_words(text)
        total_words = len(clean_words)
       
        if total_words == 0:
            print("; Error: No valid text blocks found. Safe exit execution.")
            return

        meaningful_words = [w for w in clean_words if w not in self.stop_words]
        word_counts = Counter(meaningful_words)
        frequent_words = [f"{word} ({count})" for word, count in word_counts.most_common(3)]

        long_words = [w for w in clean_words if len(w) > 8]
        complexity = round((len(long_words) / total_words) * 100)
       
        exclamations = text.count('!')
        questions = text.count('?')
        caps_words = sum(1 for w in re.findall(r'\b[А-Яа-яЁё]+\b', text) if w.isupper() and len(w) > 1)
       
        manipulation = min(round(((exclamations * 4 + questions * 3 + caps_words * 3) / total_words) * 100), 100)
        fact_density = round((len(set(clean_words)) / total_words) * 100)

        print(f"; Scanned: {total_words} words.")
        print(f"; Core Meaning: {', '.join(frequent_words) if frequent_words else 'No repetitions'}")
        print(f"• Complexity (Bureaucracy): {complexity}%")
        print(f"• Pressure (Manipulation): {manipulation}%")
        print(f"• Density (Facts vs Water): {fact_density}%")

    # MODULE 2: Детектор кликбейта (С исправленной логикой CAPS LOCK)
    def detect_clickbait(self, headline):
        self.print_header("ДЕТЕКТОР КЛИКБЕЙТА / CLICKBAIT DETECTOR")
        score = 0
        found_triggers = []
        headline_upper = headline.upper().replace('Ё', 'Е')

        for trigger in self.clickbait_triggers:
            if trigger in headline_upper:
                score += 30
                found_triggers.append(trigger)

        if headline.count('!') > 0:
            score += 20
            
        # БАГ ФИКС: Изолируем только буквы кириллицы и проверяем, был ли исходный текст в CAPS LOCK
        only_letters = re.sub(r'[^А-Яа-яЁё]', '', headline)
        if only_letters and only_letters.isupper() and len(only_letters) > 5:
            score += 30

        score = min(score, 100)
        print(f"; Headline: \"{headline}\"")
        print(f";; Toxicity Score: {score}%")
        if found_triggers:
            print(f"; Caught Triggers: {', '.join(found_triggers)}")
        print("; VERDICT: Manipulation detected!" if score > 40 else "; VERDICT: Safe, neutral headline.")

    # MODULE 3: Консольный визуализатор
    def visualize_metrics(self, text):
        self.print_header("ВИЗУАЛИЗАТОР МЫСЛИ / CONSOLE GRAPHICS")
        clean_words = self._prepare_words(text)
        total_words = len(clean_words)
       
        if total_words == 0:
            print("; Error: Graph visualization blocked. No text data available.")
            return

        long_words = [w for w in clean_words if len(w) > 8]
        complexity = round((len(long_words) / total_words) * 10)
        fact_density = round((len(set(clean_words)) / total_words) * 10)

        print("; Visual structural grid of the text:\n")
        print(f"COMPLEXITY:  " + ";" * complexity + ";" * (10 - complexity) + f" ({complexity * 10}%)")
        print(f"FACT DENSITY:" + ";" * fact_density + ";" * (10 - fact_density) + f" ({fact_density * 10}%)")

    # MODULE 4: Очиститель фраз (Генератор сути)
    def clean_phrase(self, text):
        self.print_header("ГЕНЕРАТОР ЧИСТЫХ ФРАЗ / CONTENT FILTER")
        words = re.findall(r'\b[А-Яа-яЁё]+\b', text)
        if not words:
            print("; Error: Filter blocked. Input contains no readable words.")
            return
            
        cleaned_result = [w for w in words if w.upper().replace('Ё', 'Е') not in self.stop_words]
        print("; Original raw stream:\n", text.strip())
        print("\n; Purified semantic essence:\n", " ".join(cleaned_result))
# --- MASTER TESTING CONTROLLER ---if __name__ == "__main__":
    alex_app = AlexSystemApp()

    # Тест исправленного модуля CAPS LOCK (теперь знаки препинания не ломают логику)
    headline_test = "СРОЧНО! ВЫ НЕ ПОВЕРИТЕ, ЧТО НАШЛИ УЧЕНЫЕ!"
    alex_app.detect_clickbait(headline_test)
   
    print("\n" + "=" * 60 + "\n;; STABLE PATCH V5.1 SECURED. PROCEED TO DEPLOYMENT.\n" + "=" * 60)

----------------------------


Рецензии