File size: 21,750 Bytes
9cd7d28
fc32377
5711229
3e17b19
2d1876f
473d218
2d1876f
 
 
 
 
5711229
2d1876f
 
a04d78d
 
5711229
 
2d1876f
 
 
 
 
 
 
 
 
 
 
 
 
5711229
2d1876f
 
 
 
 
 
5711229
2d1876f
 
1940bcc
 
2d1876f
1940bcc
2d1876f
1940bcc
 
 
 
 
 
 
2d1876f
 
 
 
1940bcc
 
2d1876f
1940bcc
2d1876f
 
 
1940bcc
 
2d1876f
 
1940bcc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2e4b442
 
 
 
 
 
 
 
2d1876f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1940bcc
 
2d1876f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1940bcc
 
 
 
 
2d1876f
1940bcc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2d1876f
5711229
2d1876f
 
 
 
 
 
 
fc32377
2d1876f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
076ad22
2d1876f
 
 
 
 
885c93b
2d1876f
 
 
 
 
 
 
 
 
 
6fea244
2d1876f
 
 
 
 
 
 
473d218
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
076ad22
2d1876f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
076ad22
2d1876f
 
3e17b19
2d1876f
 
 
 
 
1940bcc
2d1876f
3e17b19
 
2d1876f
 
 
 
3e17b19
2d1876f
5711229
2d1876f
 
3e17b19
2d1876f
3e17b19
2d1876f
 
 
3e17b19
2d1876f
 
1940bcc
2d1876f
 
 
 
 
 
 
5711229
2d1876f
5711229
 
2d1876f
 
5711229
2d1876f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5711229
2d1876f
5711229
 
2d1876f
 
 
6fea244
2d1876f
 
 
 
5711229
2d1876f
 
 
 
6fea244
2d1876f
 
 
 
5711229
2d1876f
 
 
076ad22
2d1876f
 
 
fc32377
2d1876f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1940bcc
2d1876f
 
 
 
1940bcc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2d1876f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e4504fe
2d1876f
 
5711229
 
 
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
import streamlit as st
import pyphen
import re
from typing import List, Tuple
import string
import os

# Initialize pyphen for syllable splitting
dic = pyphen.Pyphen(lang='en')

# Configure Streamlit page
st.set_page_config(
    page_title="Text Pronunciation Analyzer",
    page_icon="πŸ—£οΈ",
    layout="wide",
    initial_sidebar_state="collapsed"
)

# Custom CSS for styling
st.markdown("""
<style>
    .main-header {
        background: linear-gradient(90deg, #6e8efb, #a777e3);
        -webkit-background-clip: text;
        background-clip: text;
        color: transparent;
        text-align: center;
        font-size: 3rem;
        font-weight: bold;
        margin-bottom: 1rem;
    }
    
    .subtitle {
        text-align: center;
        color: #666;
        font-size: 1.2rem;
        margin-bottom: 2rem;
    }
    
    .word-highlight {
        display: inline-block;
        padding: 2px 4px;
        margin: 0 1px;
        border-radius: 4px;
        transition: all 0.3s ease;
        cursor: pointer;
        color: #666;
        background-color: transparent;
    }
    
    .word-highlight:hover {
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .pronunciation-word {
        display: inline-block;
        padding: 2px 4px;
        margin: 0 1px;
        border-radius: 4px;
        transition: all 0.3s ease;
        cursor: pointer;
        font-family: 'Courier New', monospace;
        letter-spacing: 1px;
        color: #666;
        background-color: transparent;
    }
    
    .pronunciation-word:hover {
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    /* Active states when hovered/linked */
    .word-active {
        background-color: rgba(110, 142, 251, 0.2) !important;
        color: #6e8efb !important;
        transform: translateY(-1px);
        box-shadow: 0 2px 12px rgba(110, 142, 251, 0.3);
    }
    
    .pronunciation-active {
        background-color: rgba(110, 142, 251, 0.2) !important;
        color: #6e8efb !important;
        transform: translateY(-1px);
        box-shadow: 0 2px 12px rgba(110, 142, 251, 0.3);
    }
    
    /* Color classes - only used for subtle borders */
    .color-1 { border-left: 0px solid #6e8efb; }
    .color-2 { border-left: 0px solid #a777e3; }
    .color-3 { border-left: 0px solid #4facfe; }
    .color-4 { border-left: 0px solid #00f2fe; }
    .color-5 { border-left: 0px solid #43e97b; }
    .color-6 { border-left: 0px solid #38f9d7; }
    .color-7 { border-left: 0px solid #fa709a; }
    .color-8 { border-left: 0px solid #b19709; }
    
    .pronunciation-separator {
        color: #a777e3;
        font-weight: bold;
        margin: 0 2px;
    }
    
    .analysis-card {
        background: white;
        padding: 1.5rem;
        border-radius: 12px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
        margin: 1rem 0;
    }
    
    .section-title {
        font-size: 0.9rem;
        font-weight: 600;
        color: #666;
        text-transform: uppercase;
        letter-spacing: 1px;
        margin-bottom: 0.5rem;
    }
    
    .results-text {
        font-size: 1.1rem;
        line-height: 1.8;
        color: #666;
    }
    
    .sample-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        justify-content: center;
        margin: 1rem 0;
    }
    
    .sample-btn {
        background: #f0f0f0;
        border: none;
        padding: 0.5rem 1rem;
        border-radius: 20px;
        cursor: pointer;
        transition: background-color 0.2s;
    }
    
    .sample-btn:hover {
        background: #e0e0e0;
    }
    
    .stats-container {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 1rem;
        margin: 1rem 0;
    }
    
    .stat-box {
        background: #f8f9fa;
        padding: 1rem;
        border-radius: 8px;
        text-align: center;
    }
    
    .stat-number {
        font-size: 2rem;
        font-weight: bold;
        color: #6e8efb;
    }
    
    .stat-label {
        font-size: 0.9rem;
        color: #666;
        text-transform: uppercase;
        letter-spacing: 1px;
    }
    
    /* Interactive hover JavaScript */
    .hover-container {
        position: relative;
    }
</style>

<script>
function addHoverInteraction() {
    // Add event listeners for word-syllable linking
    setTimeout(() => {
        const words = document.querySelectorAll('.word-highlight');
        const pronunciations = document.querySelectorAll('.pronunciation-word');
        
        // Clear any existing listeners
        words.forEach(word => {
            word.replaceWith(word.cloneNode(true));
        });
        pronunciations.forEach(pron => {
            pron.replaceWith(pron.cloneNode(true));
        });
        
        // Re-select after cloning
        const newWords = document.querySelectorAll('.word-highlight');
        const newPronunciations = document.querySelectorAll('.pronunciation-word');
        
        newWords.forEach((word, index) => {
            word.addEventListener('mouseenter', () => {
                // Highlight corresponding pronunciation
                word.classList.add('word-active');
                if (newPronunciations[index]) {
                    newPronunciations[index].classList.add('pronunciation-active');
                }
            });
            
            word.addEventListener('mouseleave', () => {
                // Remove highlights
                word.classList.remove('word-active');
                if (newPronunciations[index]) {
                    newPronunciations[index].classList.remove('pronunciation-active');
                }
            });
        });
        
        newPronunciations.forEach((pron, index) => {
            pron.addEventListener('mouseenter', () => {
                // Highlight corresponding word
                pron.classList.add('pronunciation-active');
                if (newWords[index]) {
                    newWords[index].classList.add('word-active');
                }
            });
            
            pron.addEventListener('mouseleave', () => {
                // Remove highlights
                pron.classList.remove('pronunciation-active');
                if (newWords[index]) {
                    newWords[index].classList.remove('word-active');
                }
            });
        });
    }, 100);
}

// Run the interaction setup when page loads
document.addEventListener('DOMContentLoaded', addHoverInteraction);
</script>
""", unsafe_allow_html=True)

class PronunciationAnalyzer:
    def __init__(self):
        self.dic = pyphen.Pyphen(lang='en')
        self.color_classes = [
            'color-1', 'color-2', 'color-3', 'color-4', 
            'color-5', 'color-6', 'color-7', 'color-8'
        ]
    
    def get_syllables(self, word: str) -> List[str]:
        """Get syllables for a word using pyphen"""
        # Remove punctuation and convert to lowercase
        clean_word = word.lower().strip(string.punctuation)
        
        if not clean_word:
            return [word]
        
        # Use pyphen to split into syllables
        syllables = self.dic.inserted(clean_word).split('-')
        
        # If pyphen couldn't split (returns original word), try basic vowel-based splitting
        if len(syllables) == 1 and len(clean_word) > 3:
            syllables = self._basic_syllable_split(clean_word)
        
        return syllables if syllables else [word]
    
    def _basic_syllable_split(self, word: str) -> List[str]:
        """Basic vowel-based syllable splitting as fallback"""
        vowels = 'aeiouy'
        syllables = []
        current_syllable = ''
        
        for i, char in enumerate(word):
            current_syllable += char
            
            # Look ahead for vowel patterns
            if i < len(word) - 1:
                if char in vowels and word[i + 1] not in vowels:
                    # Vowel followed by consonant - potential syllable break
                    if len(current_syllable) >= 2:
                        syllables.append(current_syllable)
                        current_syllable = ''
        
        if current_syllable:
            syllables.append(current_syllable)
        
        return syllables if syllables else [word]
    
    def tokenize_text(self, text: str) -> List[str]:
        """Tokenize text into words while preserving punctuation"""
        # Enhanced regex-based tokenization
        # This pattern matches:
        # - Words (including contractions like "don't")
        # - Numbers
        # - Punctuation marks
        # - Preserves spacing
        
        # Split text into tokens while preserving structure
        pattern = r"(?:\w+(?:'\w+)?|\d+|[^\w\s])"
        tokens = re.findall(pattern, text)
        
        # Add spaces back where needed
        result = []
        text_pos = 0
        
        for token in tokens:
            # Find the token's position in the original text
            token_pos = text.find(token, text_pos)
            
            # Add any whitespace before the token
            if token_pos > text_pos:
                whitespace = text[text_pos:token_pos]
                if whitespace.strip() == '':  # Only add if it's pure whitespace
                    result.extend(list(whitespace))
            
            result.append(token)
            text_pos = token_pos + len(token)
        
        # Filter out empty strings and normalize
        return [token for token in result if token.strip()]
    
    def analyze_text(self, text: str) -> Tuple[List[Tuple[str, List[str]]], dict]:
        """Analyze text and return word-syllable pairs and statistics"""
        if not text.strip():
            return [], {}
        
        # Tokenize the text
        words = self.tokenize_text(text)
        
        # Filter out pure punctuation tokens for analysis
        content_words = [word for word in words if any(c.isalnum() for c in word)]
        
        # Get syllables for each word
        word_syllables = []
        total_syllables = 0
        
        for word in words:
            if any(c.isalnum() for c in word):  # Only analyze words with alphanumeric characters
                syllables = self.get_syllables(word)
                word_syllables.append((word, syllables))
                total_syllables += len(syllables)
            else:
                word_syllables.append((word, [word]))  # Keep punctuation as-is
        
        # Calculate statistics
        stats = {
            'total_words': len(content_words),
            'total_syllables': total_syllables,
            'avg_syllables': round(total_syllables / len(content_words), 2) if content_words else 0,
            'longest_word': max(content_words, key=len) if content_words else '',
            'most_syllables': max(content_words, key=lambda w: len(self.get_syllables(w))) if content_words else ''
        }
        
        return word_syllables, stats

def render_highlighted_text(word_syllables: List[Tuple[str, List[str]]], analyzer: PronunciationAnalyzer):
    """Render original text with word highlighting"""
    html_parts = []
    word_index = 0
    
    for word, syllables in word_syllables:
        if any(c.isalnum() for c in word):
            color_class = analyzer.color_classes[word_index % len(analyzer.color_classes)]
            html_parts.append(f'<span class="word-highlight {color_class}" data-word-index="{word_index}">{word}</span>')
            word_index += 1
        else:
            html_parts.append(word)
        
        # Add space after word (except for punctuation that shouldn't have spaces)
        if word not in '.,!?;:':
            html_parts.append(' ')
    
    return ''.join(html_parts)

def render_pronunciation(word_syllables: List[Tuple[str, List[str]]], analyzer: PronunciationAnalyzer):
    """Render pronunciation with syllable breakdown"""
    html_parts = []
    word_index = 0
    
    for word, syllables in word_syllables:
        if any(c.isalnum() for c in word):
            color_class = analyzer.color_classes[word_index % len(analyzer.color_classes)]
            
            # Join syllables with dots
            syllable_text = '<span class="pronunciation-separator">Β·</span>'.join(syllables)
            html_parts.append(f'<span class="pronunciation-word {color_class}" data-word-index="{word_index}">{syllable_text}</span>')
            word_index += 1
        else:
            html_parts.append(f'<span class="pronunciation-word">{word}</span>')
        
        # Add space after word (except for punctuation that shouldn't have spaces)
        if word not in '.,!?;:':
            html_parts.append(' ')
    
    return ''.join(html_parts)

def main():
    # Initialize analyzer
    analyzer = PronunciationAnalyzer()
    
    # Header
    st.markdown('<h1 class="main-header">πŸ—£οΈ Text Pronunciation Analyzer</h1>', unsafe_allow_html=True)
    st.markdown('<p class="subtitle">Enter any text below to see its pronunciation breakdown with advanced syllable detection</p>', unsafe_allow_html=True)
    
    # Input section
    st.markdown("### πŸ“ Enter Your Text")
    
    # Sample texts
    sample_texts = [
        "Hello world",
        "Pronunciation analyzer",
        "Supercalifragilisticexpialidocious",
        "Linguistics and phonetics",
        "The quick brown fox jumps over the lazy dog"
    ]
    
    # Sample buttons
    st.markdown("**Try these samples:**")
    cols = st.columns(len(sample_texts))
    for i, sample in enumerate(sample_texts):
        if cols[i].button(sample, key=f"sample_{i}"):
            st.session_state.input_text = sample
    
    # Text input
    text_input = st.text_area(
        "Text to analyze:",
        value=st.session_state.get('input_text', ''),
        height=120,
        placeholder="Type or paste your text here...",
        key="text_input"
    )
    
    # Update session state
    if text_input:
        st.session_state.input_text = text_input
    
    # Analyze button
    col1, col2, col3 = st.columns([1, 1, 1])
    with col2:
        analyze_button = st.button("πŸ” Analyze Text", type="primary", use_container_width=True)
    
    # Clear button
    if st.button("πŸ—‘οΈ Clear"):
        st.session_state.input_text = ""
        st.rerun()
    
    # Analysis results
    if analyze_button and text_input.strip():
        with st.spinner("Analyzing text..."):
            word_syllables, stats = analyzer.analyze_text(text_input)
        
        if word_syllables:
            st.markdown("---")
            st.markdown("## πŸ“Š Analysis Results")
            
            # Statistics
            st.markdown("### πŸ“ˆ Text Statistics")
            col1, col2, col3, col4 = st.columns(4)
            
            with col1:
                st.markdown(f"""
                <div class="stat-box">
                    <div class="stat-number">{stats['total_words']}</div>
                    <div class="stat-label">Words</div>
                </div>
                """, unsafe_allow_html=True)
            
            with col2:
                st.markdown(f"""
                <div class="stat-box">
                    <div class="stat-number">{stats['total_syllables']}</div>
                    <div class="stat-label">Syllables</div>
                </div>
                """, unsafe_allow_html=True)
            
            with col3:
                st.markdown(f"""
                <div class="stat-box">
                    <div class="stat-number">{stats['avg_syllables']}</div>
                    <div class="stat-label">Avg/Word</div>
                </div>
                """, unsafe_allow_html=True)
            
            with col4:
                longest_syllables = len(analyzer.get_syllables(stats['most_syllables']))
                st.markdown(f"""
                <div class="stat-box">
                    <div class="stat-number">{longest_syllables}</div>
                    <div class="stat-label">Max Syllables</div>
                </div>
                """, unsafe_allow_html=True)
            
            # Original text with highlights
            st.markdown("### πŸ“– Original Text")
            original_html = render_highlighted_text(word_syllables, analyzer)
            st.markdown(f'<div class="analysis-card hover-container"><div class="results-text">{original_html}</div></div>', unsafe_allow_html=True)
            
            # Pronunciation breakdown
            st.markdown("### πŸ”€ Pronunciation Breakdown")
            pronunciation_html = render_pronunciation(word_syllables, analyzer)
            st.markdown(f'<div class="analysis-card hover-container"><div class="results-text">{pronunciation_html}</div></div>', unsafe_allow_html=True)
            
            # Add JavaScript for hover interaction
            st.components.v1.html("""
            <script>
            function addHoverInteraction() {
                const words = parent.document.querySelectorAll('.word-highlight');
                const pronunciations = parent.document.querySelectorAll('.pronunciation-word');
                
                // Clear existing event listeners by cloning nodes
                words.forEach((word, index) => {
                    const wordIndex = word.getAttribute('data-word-index');
                    if (wordIndex !== null) {
                        const newWord = word.cloneNode(true);
                        word.parentNode.replaceChild(newWord, word);
                        
                        newWord.addEventListener('mouseenter', () => {
                            newWord.classList.add('word-active');
                            const correspondingPron = parent.document.querySelector(`[data-word-index="${wordIndex}"].pronunciation-word`);
                            if (correspondingPron) {
                                correspondingPron.classList.add('pronunciation-active');
                            }
                        });
                        
                        newWord.addEventListener('mouseleave', () => {
                            newWord.classList.remove('word-active');
                            const correspondingPron = parent.document.querySelector(`[data-word-index="${wordIndex}"].pronunciation-word`);
                            if (correspondingPron) {
                                correspondingPron.classList.remove('pronunciation-active');
                            }
                        });
                    }
                });
                
                pronunciations.forEach((pron, index) => {
                    const wordIndex = pron.getAttribute('data-word-index');
                    if (wordIndex !== null) {
                        const newPron = pron.cloneNode(true);
                        pron.parentNode.replaceChild(newPron, pron);
                        
                        newPron.addEventListener('mouseenter', () => {
                            newPron.classList.add('pronunciation-active');
                            const correspondingWord = parent.document.querySelector(`[data-word-index="${wordIndex}"].word-highlight`);
                            if (correspondingWord) {
                                correspondingWord.classList.add('word-active');
                            }
                        });
                        
                        newPron.addEventListener('mouseleave', () => {
                            newPron.classList.remove('pronunciation-active');
                            const correspondingWord = parent.document.querySelector(`[data-word-index="${wordIndex}"].word-highlight`);
                            if (correspondingWord) {
                                correspondingWord.classList.remove('word-active');
                            }
                        });
                    }
                });
            }
            
            // Run interaction setup
            setTimeout(addHoverInteraction, 300);
            </script>
            """, height=0)
            
            # Word-by-word breakdown
            st.markdown("### πŸ“ Word-by-Word Analysis")
            
            # Create expandable sections for detailed breakdown
            content_words = [(word, syllables) for word, syllables in word_syllables if any(c.isalnum() for c in word)]
            
            if content_words:
                # Group words into rows of 3
                for i in range(0, len(content_words), 3):
                    cols = st.columns(3)
                    for j, (word, syllables) in enumerate(content_words[i:i+3]):
                        with cols[j]:
                            st.markdown(f"""
                            <div style="background: #f8f9fa; padding: 1rem; border-radius: 8px; margin-bottom: 0.5rem;">
                                <div style="font-weight: bold; color: #333; margin-bottom: 0.5rem;">{word}</div>
                                <div style="color: #666; font-family: monospace;">{'Β·'.join(syllables)}</div>
                                <div style="color: #999; font-size: 0.8rem;">{len(syllables)} syllable{'s' if len(syllables) != 1 else ''}</div>
                            </div>
                            """, unsafe_allow_html=True)
    
    elif analyze_button:
        st.warning("Please enter some text to analyze.")
    
    # Footer
    st.markdown("---")
    st.markdown(
        '<div style="text-align: center; color: #666; padding: 2rem;">Created by @aghilalb and ai</div>',
        unsafe_allow_html=True
    )

if __name__ == "__main__":
    main()