File size: 2,819 Bytes
9c53557
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
"""
Utility functions for the Revert text transformation application.
"""

import re
from typing import List, Tuple

def sanitize_input(text: str) -> str:
    """
    Basic input sanitization for text processing.
    
    Args:
        text (str): Input text to sanitize
    
    Returns:
        str: Sanitized text
    """
    if not text:
        return ""
    
    # Remove potentially harmful characters while preserving text structure
    sanitized = re.sub(r'[<>"\']', '', text)
    return sanitized.strip()

def validate_intensity(intensity: float) -> float:
    """
    Ensure intensity is within valid range.
    
    Args:
        intensity (float): Input intensity value
    
    Returns:
        float: Validated intensity value
    """
    return max(0.0, min(1.0, intensity))

def get_operation_description(operation: str) -> str:
    """
    Get a human-readable description of each operation.
    
    Args:
        operation (str): Name of the operation
    
    Returns:
        str: Description of what the operation does
    """
    descriptions = {
        "Reverse": "Reverses the entire text character by character",
        "Uppercase": "Converts all text to upper case",
        "Lowercase": "Converts all text to lower case",
        "Title Case": "Capitalizes the first letter of each word",
        "Random Case": "Randomly capitalizes letters based on intensity",
        "Alternating Case": "Alternates between upper and lower case",
        "Spongebob Mock": "Applies the Spongebob mocking text style",
        "Leet Speak": "Converts text to leet (1337) speak",
        "Add Emojis": "Adds random emojis throughout the text",
        "Shuffle Words": "Randomly reorders words in the text",
        "Duplicate Letters": "Duplicates random letters based on intensity"
    }
    
    return descriptions.get(operation, "No description available.")

This Gradio 6 application "Revert" provides:

**Features:**
- Text reversal (classic "revert" functionality)
- Case transformations (upper, lower, title)
- Random case with adjustable intensity
- Alternating case patterns
- Spongebob mocking text style
- Leet speak conversion
- Word shuffling
- Letter duplication

**Gradio 6 Modern Features:**
- Custom theme with Soft design
- Google Font integration (Inter)
- Professional color scheme (indigo primary)
- Responsive layout with rows and columns
- Interactive sliders for intensity control
- Example generation
- Built-in error handling
- Clean, modern UI with proper spacing and sizing

**User Experience:**
- Intuitive interface with clear labels
- Example section for quick testing
- Real-time feedback
- Multiple transformation options
- Adjustable intensity for fine control

The app uses proper Gradio 6 syntax with theme customization in `demo.launch()` and modern component APIs.