File size: 26,840 Bytes
eafe84d
 
6a0d5d5
f04a4d6
6a0d5d5
 
 
 
 
 
 
 
f04a4d6
6a0d5d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3ad4835
 
6a0d5d5
3ad4835
6a0d5d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3ad4835
 
6a0d5d5
 
3ad4835
 
6a0d5d5
3ad4835
6a0d5d5
 
3ad4835
6a0d5d5
3ad4835
 
6a0d5d5
3ad4835
6a0d5d5
 
3ad4835
 
 
 
 
 
6a0d5d5
3ad4835
6a0d5d5
 
3ad4835
 
 
 
 
 
6a0d5d5
3ad4835
6a0d5d5
 
3ad4835
 
 
6a0d5d5
 
 
 
 
3ad4835
 
6a0d5d5
3ad4835
6a0d5d5
 
3ad4835
 
 
 
6a0d5d5
 
3ad4835
 
6a0d5d5
3ad4835
6a0d5d5
 
3ad4835
6a0d5d5
 
3ad4835
 
6a0d5d5
3ad4835
6a0d5d5
 
3ad4835
6a0d5d5
3ad4835
 
6a0d5d5
3ad4835
6a0d5d5
 
3ad4835
 
6a0d5d5
 
3ad4835
 
6a0d5d5
3ad4835
6a0d5d5
 
3ad4835
 
6a0d5d5
 
3ad4835
 
6a0d5d5
3ad4835
6a0d5d5
 
3ad4835
 
6a0d5d5
 
 
 
 
 
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
import streamlit as st

# Sidebar for navigation
sidebar = st.sidebar

# Sidebar header
sidebar.header('🌐 NLP Exploration')

# Sidebar options for NLP Overview, Lifecycle, and Techniques
sidebar_option = sidebar.radio('Choose a section to explore:', ['🧠 What is NLP?', 'πŸ”„ NLP Lifecycle', 'βš™οΈ NLP Techniques'])

# Store the selected page in session state
if 'selected_page' not in st.session_state:
    st.session_state.selected_page = sidebar_option

# Update the selected page if the user selects a different option
if sidebar_option != st.session_state.selected_page:
    st.session_state.selected_page = sidebar_option

# Dynamically update the title based on the selected option
def set_title(title, color="black"):
    st.markdown(f"<h1 style='text-align: center; color: {color}; font-size: 36px;'>{title}</h1>", unsafe_allow_html=True)

# Function to add a paragraph with consistent formatting
def add_paragraph(content):
    st.markdown(f"<p style='font-size: 16px; line-height: 1.6;'>{content}</p>", unsafe_allow_html=True)

# Function for adding a bullet list
def add_bullet_list(items):
    for item in items:
        st.markdown(f"- {item}", unsafe_allow_html=True)

# Content for "What is NLP?"
if st.session_state.selected_page == '🧠 What is NLP?':
    set_title('Introduction to Natural Language Processing (NLP)', color="darkblue")

    st.markdown("<h2 style='text-align: center; color: darkblue;'>πŸ“˜ What is NLP?</h2>", unsafe_allow_html=True)
    
    add_paragraph("""
    Natural Language Processing (NLP) is a branch of Artificial Intelligence (AI) that focuses on enabling computers to understand, interpret, and generate human language in a way that is meaningful. NLP allows machines to process and analyze large amounts of unstructured natural language data, including text and speech.
    """)

    st.markdown("<h3 style='text-align: center; color: darkgreen;'>Key Concepts of NLP</h3>", unsafe_allow_html=True)
    
    add_bullet_list([
        "πŸ”  **Syntax**: The arrangement of words in a sentence to ensure proper structure.",
        "πŸ’¬ **Semantics**: The study of meaning in words and sentences.",
        "🌍 **Pragmatics**: How context influences the interpretation of language.",
        "πŸ”„ **Discourse**: The way that meaning is influenced by the flow of conversation or written text."
    ])
    
    st.markdown("<h3 style='text-align: center; color: darkgreen;'>Applications of NLP</h3>", unsafe_allow_html=True)

    add_bullet_list([
        "🌐 **Machine Translation**: Translating text between languages, such as Google Translate.",
        "πŸ—£οΈ **Speech Recognition**: Converting spoken language into text, as seen in Siri or Google Assistant.",
        "πŸ’­ **Sentiment Analysis**: Analyzing text to determine its sentiment, such as positive or negative reviews.",
        "✍️ **Text Summarization**: Creating concise summaries from longer texts, such as news articles."
    ])
    
    add_paragraph("""
    NLP is used in a wide variety of industries like healthcare, finance, and customer service to automate tasks, analyze data, and improve customer experiences. By enabling computers to process human language, NLP opens up new possibilities for innovation and efficiency.
    """)

# Content for NLP Lifecycle
elif st.session_state.selected_page == "πŸ”„ NLP Lifecycle":
    lifecycle_option = sidebar.radio("Select NLP Lifecycle Step:", [
        "🌐 Overview of the NLP Life Cycle",
        "🎯 Problem Definition",
        "πŸ“Š Data Collection",
        "πŸ“ˆ Simple EDA",
        "🧹 Data Preprocessing",
        "πŸ“ Feature Engineering",
        "πŸ‹οΈβ€β™‚οΈ Model Training",
        "πŸ… Evaluation",
        "πŸš€ Deployment"
    ])

    if lifecycle_option == "🌐 Overview of the NLP Life Cycle":
        set_title('NLP Life Cycle Overview', color="darkblue")
        
        add_paragraph("""
        The NLP lifecycle is a comprehensive process that involves several key stages, from defining the problem to deploying a model and maintaining it. Each step plays a crucial role in transforming raw text data into actionable insights or automated systems. The stages can be broken down as follows:
        """)

        add_bullet_list([
            "1. **Problem Definition**: Identifying the business problem that can be solved using NLP.",
            "2. **Data Collection**: Gathering relevant textual data that will be used to train models.",
            "3. **Exploratory Data Analysis (EDA)**: Understanding the data's structure, identifying patterns, and spotting potential issues.",
            "4. **Data Preprocessing**: Cleaning and formatting data to prepare it for analysis, such as removing noise or handling missing values.",
            "5. **Feature Engineering**: Creating new features or selecting important attributes to improve model performance.",
            "6. **Model Training**: Selecting the appropriate algorithms and training models using the prepared data.",
            "7. **Evaluation**: Assessing the model's accuracy and performance using various metrics like precision, recall, and F1-score.",
            "8. **Deployment**: Implementing the model into a production environment, ready for real-world use.",
            "9. **Monitoring and Maintenance**: Continuously checking model performance and making updates to keep it effective."
        ])

        add_paragraph("""
        The NLP lifecycle is iterative; as new data becomes available or requirements change, steps like model retraining and maintenance are necessary. This ensures that NLP systems remain relevant and effective over time.
        """)

    # More specific steps in NLP lifecycle would go here based on lifecycle_option selection...

# Content for NLP Techniques
elif st.session_state.selected_page == 'βš™οΈ NLP Techniques':
    set_title('Techniques in Natural Language Processing', color="darkblue")

    st.markdown("<h2 style='text-align: center; color: darkblue;'>πŸ”§ Key NLP Techniques</h2>", unsafe_allow_html=True)

    add_paragraph("""
    NLP involves several techniques and algorithms to process and analyze text data effectively. Some of the key techniques include:
    """)

    add_bullet_list([
        "🧠 **Tokenization**: Breaking text into smaller units like words or sentences to make it easier to process.",
        "πŸ”€ **Stemming and Lemmatization**: Reducing words to their base or root form to standardize text (e.g., 'running' to 'run').",
        "🎯 **Named Entity Recognition (NER)**: Identifying entities like names, dates, or locations within text.",
        "πŸ’‘ **Part-of-Speech Tagging**: Assigning a part of speech (e.g., noun, verb) to each word in a sentence.",
        "πŸ” **Word Embeddings**: Mapping words into numerical vectors (e.g., Word2Vec, GloVe) to capture semantic meaning.",
        "🌐 **Topic Modeling**: Grouping a set of documents into topics based on common themes, using techniques like LDA (Latent Dirichlet Allocation)."
    ])

    add_paragraph("""
    These techniques are essential for tasks like machine translation, sentiment analysis, and chatbot development. NLP models that leverage these techniques can understand and generate human language with remarkable accuracy.
    """)
import streamlit as st

# Sidebar for navigation
sidebar = st.sidebar

# Sidebar header
sidebar.header('🌐 NLP Navigation')

# Sidebar options for NLP Overview, Lifecycle, and Techniques
sidebar_option = sidebar.radio('Choose a section to explore:', ['🧠What is NLP?', 'πŸ”„NLP Lifecycle', 'βš™οΈNLP Techniques'])

# Store the selected page in session state
if 'selected_page' not in st.session_state:
    st.session_state.selected_page = sidebar_option

# Update the selected page if the user selects a different option
if sidebar_option != st.session_state.selected_page:
    st.session_state.selected_page = sidebar_option

# Dynamically update the title based on the selected option
def set_title(title, color="black"):
    st.markdown(f"<h1 style='text-align: center; color: {color};'>{title}</h1>", unsafe_allow_html=True)

if st.session_state.selected_page == '🧠What is NLP?':
    set_title('Understanding Natural Language Processing (NLP)', color="darkgreen")
    
elif st.session_state.selected_page == 'πŸ”„NLP Lifecycle':
    set_title('NLP Lifecycle: From Data Collection to Deployment', color="darkgreen")

elif st.session_state.selected_page == 'βš™οΈNLP Techniques':
    set_title('NLP Techniques: Methods and Applications', color="darkgreen")

# Content for "What is NLP?"
if st.session_state.selected_page == '🧠What is NLP?':
    st.markdown("<h2 style='text-align: center; color: darkgreen;'>πŸ“˜ Introduction to NLP</h2>", unsafe_allow_html=True)
    st.write("""
    #### πŸ€– What is NLP?
    Natural Language Processing (NLP) is a subfield of Artificial Intelligence (AI) focused on the interaction between computers and human languages. Its goal is to enable machines to understand, interpret, and generate human language meaningfully.
    
    NLP allows machines to analyze vast amounts of natural language data, such as:
    - πŸ“œ Text from documents
    - πŸ—£οΈ Speech from conversations
    - πŸ–ΌοΈ Images with textual descriptions
    
    #### Key Components of NLP:
    - **Syntax**: The structure of sentences and the arrangement of words.
    - **Semantics**: The meaning of words and how they are used.
    - **Pragmatics**: Understanding language in context, including the speaker's intent.
    - **Discourse**: Analyzing the structure and flow of sentences in a larger context.
    
    #### Applications of NLP:
    - **Machine Translation**: Translating text from one language to another (e.g., Google Translate).
    - **Speech Recognition**: Converting spoken words into written text (e.g., Siri, Alexa).
    - **Sentiment Analysis**: Determining the sentiment behind a text (positive, negative, or neutral).
    - **Text Summarization**: Automatically generating a concise version of a text (e.g., summarizing articles).
    
    NLP has significant applications in various fields like healthcare, finance, customer service, and many others.
    """)

# Content for NLP Lifecycle
elif st.session_state.selected_page == "πŸ”„NLP Lifecycle":
    lifecycle_option = sidebar.radio("Select NLP Lifecycle Step:", [
        "🌐 Overview of the NLP Life Cycle",
        "🎯 Problem Definition",
        "πŸ“Š Data Collection",
        "πŸ“ˆ Simple EDA",
        "🧹 Data Preprocessing",
        "πŸ“ Feature Engineering",
        "πŸ‹οΈβ€β™‚οΈ Model Training",
        "πŸ… Model Evaluation",
        "πŸš€ Deployment"
    ])

    if lifecycle_option == "🌐 Overview of the NLP Life Cycle":
        st.write("""
        #### Overview of the NLP Life Cycle:
        The NLP life cycle outlines a structured approach to building, deploying, and maintaining systems that handle human language. It turns unstructured text into actionable insights, making the process flexible and adaptive to real-world changes.
    
        - **The Process Flow**:
            1. Problem identification and text data collection.
            2. Data cleaning and preprocessing.
            3. Model building and testing.
            4. Continuous monitoring and updates to ensure optimal performance.
    
        - **Key Features**:
            - Flexible and adaptive: The NLP life cycle evolves as language, trends, and data change.
            - Cross-disciplinary: Combines expertise from linguistics, computer science, and data analysis.
            - Practical and scalable: Solutions are designed to be implemented in real-world applications.
    
        #### Major Stages in the NLP Life Cycle:
        1. πŸ”§ Problem Definition 
        2. πŸ“Š Data Collection
        3. πŸ” Simple EDA (Exploratory Data Analysis)
        4. 🧹 Data Preprocessing
        5. πŸ“ Feature Engineering
        6. πŸ‹οΈβ€β™‚οΈ Model Training
        7. πŸ… Model Evaluation
        8. βš™οΈ Model Tuning
        9. πŸš€ Deployment
        10. πŸ› οΈ Monitoring and Maintenance
        """)

    elif lifecycle_option == "🎯 Problem Definition":
        st.write("""
        #### πŸ”§ 1. Problem Definition:
        The first step in the NLP lifecycle is defining the problem. Understanding the objective is key to determining how NLP can be applied.
    
        - **Key Questions to Define the Problem**:
            - 🎯 What is the goal of this analysis (e.g., sentiment classification, topic modeling)?
            - πŸ“ What type of data are we dealing with (e.g., reviews, articles, social media posts)?
            - πŸ“Š What is the desired outcome (e.g., sentiment score, summary, or label)?
    
        **Example Problem**: Classifying customer reviews as positive or negative.
        """)

    elif lifecycle_option == "πŸ“Š Data Collection":
        st.write("""
        #### πŸ“š 2. Data Collection:
        Data collection is the foundation of the NLP process. It involves gathering relevant textual data from multiple sources.
    
        - **Common Data Collection Methods**:
            - 🌐 Public datasets (e.g., Kaggle, government websites).
            - πŸ”Œ APIs for data retrieval (e.g., Twitter API for tweets).
            - πŸ•ΈοΈ Web scraping (e.g., using BeautifulSoup or Scrapy).
            - βœ‹ Manual data entry in some cases.
    
        **Example**: Scraping product reviews from e-commerce websites to analyze customer sentiment.
    
        #### Extracting Data from Files:
        Once data is collected, it’s often in formats like CSV, JSON, or Excel. Tools like **Pandas** in Python can be used to extract and structure this data for analysis.
    
        **Steps**:
        - Identify the file format (e.g., `.csv`, `.json`).
        - Use functions like `pd.read_csv()` to load the data into a Pandas DataFrame.
        - Clean and verify the data using methods like `df.head()` or `df.info()` to inspect the first few records and data types.
    
        **Code Example**:
        ```python
        import pandas as pd

        # Extracting Data from a CSV File
        df = pd.read_csv('data.csv')
        print(df.head())
        ```
        """)

    elif lifecycle_option == "πŸ“ˆ Simple EDA":
        st.write("""
        #### πŸ” 3. Simple EDA (Exploratory Data Analysis):
        Simple EDA provides an initial understanding of the data. It helps identify patterns, outliers, and potential issues that may impact the analysis.
    
        - **Key Tasks in EDA**:
            - Check the data balance: Is the data evenly distributed or skewed?
            - Visualize distributions: Use histograms and boxplots.
            - Check for missing data: Identify any gaps in the data.
            - Outlier detection: Spot extreme values and decide whether to keep or remove them.
    
        **Example**: In a classification dataset, check for a 70:30 imbalance between positive and negative classes.
        """)

    elif lifecycle_option == "🧹 Data Preprocessing":
        st.write("""
        #### 🧹 4. Text Preprocessing:
        Text preprocessing is essential for converting raw text into a format suitable for analysis or model training.
    
        **Steps in Text Preprocessing**:
        - **Tokenization**: Splitting text into smaller pieces (words or sentences).
        - **Removing Stopwords**: Eliminate common, less meaningful words (e.g., 'the', 'and').
        - **Stemming and Lemmatization**: Reduce words to their root forms (e.g., 'running' to 'run').
        - **Removing Special Characters**: Strip out unnecessary symbols, emojis, and URLs.
    
        **Code Example**:
        ```python
        import re

        # Sample text
        text = "The quick brown fox 🦊 jumps over the lazy dog!"

        # Remove special characters
        clean_text = re.sub(r'[^a-zA-Z\s]', '', text)
        print(clean_text)
        ```
        **Output**: "The quick brown fox jumps over the lazy dog"
        """)

    elif lifecycle_option == "πŸ“ Feature Engineering":
        st.write("""
        #### πŸ“ 5. Feature Engineering:
        After preprocessing, the text must be transformed into a numerical representation for machine learning models.
    
        **Common Feature Engineering Techniques**:
        - **Bag of Words (BoW)**: Counts the frequency of words in the text.
        - **TF-IDF**: Measures word importance based on frequency and rarity.
        - **Word Embeddings**: Transforms words into dense vectors (e.g., Word2Vec, GloVe).
    
        **Example**: Converting the sentence "I love NLP" into a numerical vector using BoW.
        """)

    elif lifecycle_option == "πŸ‹οΈβ€β™‚οΈ Model Training":
        st.write("""
        #### πŸ‹οΈβ€β™‚οΈ 6. Model Training:
        Once the data is preprocessed, we can train machine learning models on it. The choice of model depends on the NLP task (e.g., classification, sentiment analysis).
    
        **Common Models**:
        - **Text Classification**: Naive Bayes, SVM, or deep learning models.
        - **Sentiment Analysis**: Logistic Regression, Naive Bayes, BERT.
    
        **Example**: Training a Naive Bayes model to classify text into categories like "Sports", "Politics", etc.
        """)

    elif lifecycle_option == "πŸ… Model Evaluation":
        st.write("""
        #### πŸ… 7. Model Evaluation:
        Evaluating the performance of your model is crucial to ensure its reliability.
    
        - **Metrics**: Accuracy, Precision, Recall, F1-Score.
        - **Confusion Matrix**: Visual representation of true positives, false positives, etc.
    
        **Example**: Evaluating a sentiment analysis model with accuracy and F1-score on test data.
        """)

    elif lifecycle_option == "πŸš€ Deployment":
        st.write("""
        #### πŸš€ 8. Deployment:
        Once the model is trained and evaluated, it is deployed to production for real-time use.
    
        **Key Steps**:
        - **Integration**: Connecting the model with a live application (e.g., a chatbot).
        - **Monitoring**: Regularly tracking the model’s performance over time.
        - **Updating**: Periodically retraining the model with new data.
    
        **Example**: Deploying a sentiment analysis model via a REST API to evaluate customer reviews in real-time.
        """)

# Content for NLP Techniques
elif st.session_state.selected_page == "βš™οΈNLP Techniques":
    st.write("""
    #### βš™οΈ Common NLP Techniques:
    There are several techniques in NLP that enable computers to process language in meaningful ways.
    
    **1. Tokenization**: Breaking text into individual words or phrases.
    
    **2. Named Entity Recognition (NER)**: Identifying entities such as names, locations, dates, etc.
    
    **3. Part-of-Speech (POS) Tagging**: Labeling words based on their parts of speech (e.g., noun, verb).
    
    **4. Sentiment Analysis**: Determining the sentiment expressed in the text (positive, negative, or neutral).
    
    **5. Word Embeddings**: Converting words into high-dimensional vectors to capture semantic meaning.
    
    **6. Text Classification**: Assigning predefined labels to text (e.g., spam detection, topic categorization).
    
    **7. Machine Translation**: Translating text from one language to another.
    
    **8. Text Summarization**: Condensing long texts into shorter, meaningful summaries.
    """)

# Content for "NLP Techniques"
elif st.session_state.selected_page == "βš™οΈNLP Techniques":
    technique_option = sidebar.radio("Select an NLP Technique:", [
        "NLP Techniques Overview",
        "Tokenization",
        "Stop Words Removal",
        "Lemmatization",
        "Stemming",
        "One-Hot Encoding",
        "Bag of Words (BoW)",
        "TF-IDF",
        "Word Embeddings",
        "Named Entity Recognition (NER)",
        "Part-of-Speech (POS) Tagging",
        "Sentiment Analysis"
    ])

    if technique_option == "NLP Techniques Overview":
        st.write("""
        ### βš™οΈ Key NLP Techniques
        Natural Language Processing (NLP) involves a variety of techniques for processing and analyzing text data. Here are some of the most important methods:
        
        1. **Tokenization**: Breaking text into smaller units such as words or sentences.
        2. **Part-of-Speech (POS) Tagging**: Identifying the grammatical role of words in a sentence (e.g., noun, verb, adjective).
        3. **Named Entity Recognition (NER)**: Identifying and classifying entities like names, dates, and locations.
        4. **Dependency Parsing**: Analyzing the syntactic structure of sentences.
        5. **Sentiment Analysis**: Determining the sentiment expressed in the text (positive, negative, or neutral).
        6. **Word Embeddings**: Representing words as vectors in continuous space to capture semantic relationships (e.g., Word2Vec, GloVe).
        
        **Example**: Sentiment analysis can identify whether customer reviews are positive, negative, or neutral based on the words used in the text.
        """)

    elif technique_option == "Tokenization":
        st.write("""
        #### 1. Tokenization
        Tokenization is the process of breaking text into smaller units, known as tokens. Tokens can be words, sentences, or subwords. This step is essential for most NLP tasks, as it provides the foundation for further analysis.
        
        - **Example**:
          - Sentence: "Natural Language Processing is amazing!"
          - Tokenized words: `["Natural", "Language", "Processing", "is", "amazing"]`
        """)

    elif technique_option == "Stop Words Removal":
        st.write("""
        #### 2. Stop Words Removal
        Stop words are common words (like 'the', 'and', 'in', etc.) that often do not carry much significant meaning for text analysis. Removing them helps reduce the dimensionality of the text and the noise in the dataset.
        
        - **Example**: In the sentence "NLP is fun!", the stop word "is" may be removed, leaving "NLP" and "fun" for analysis.
        """)

    elif technique_option == "Lemmatization":
        st.write("""
        #### 3. Lemmatization
        Lemmatization is the process of reducing a word to its base or root form based on its meaning. It considers the context of the word in a sentence and ensures that the resulting word is a valid word in the language.
        
        - **Example**:
          - "Better" β†’ "Good"
          - "Running" β†’ "Run"
        """)

    elif technique_option == "Stemming":
        st.write("""
        #### 4. Stemming
        Stemming is similar to lemmatization but is a simpler, rule-based approach. It involves chopping off prefixes or suffixes from words to reduce them to a root form, which may not always be a valid word.
        
        - **Example**:
          - "Running" β†’ "Run"
          - "Happiness" β†’ "Happi"
        """)

    elif technique_option == "One-Hot Encoding":
        st.write("""
        #### 5. One-Hot Encoding
        One-Hot Encoding is a technique where each word in the vocabulary is represented as a binary vector. Each word is assigned a unique index, and the corresponding vector has a 1 at that index and 0 elsewhere.
        
        - **Example**:
          - Vocabulary: `["cat", "dog", "fish"]`
          - Encoding for "cat": `[1, 0, 0]`
          - Encoding for "dog": `[0, 1, 0]`
          
        **Pros**: Simple and easy to implement.
        **Cons**: Results in sparse vectors and can create high-dimensional spaces when the vocabulary is large.
        """)

    elif technique_option == "Bag of Words (BoW)":
        st.write("""
        #### 6. Bag of Words (BoW)
        The Bag of Words model represents text as an unordered collection of words, without considering grammar or word order. This technique is commonly used for text classification and representation.
        
        - **Example**:
          - Text: "I love NLP"
          - BoW: `{"I": 1, "love": 1, "NLP": 1}`
          
        This model simply counts the frequency of each word in the text.
        """)

    elif technique_option == "TF-IDF":
        st.write("""
        #### 7. TF-IDF (Term Frequency-Inverse Document Frequency)
        TF-IDF is a statistical measure used to evaluate the importance of a word within a document, considering its frequency in that document and its inverse frequency across a collection of documents.
        
        - **Example**:
          - In a document about data analysis, the word "data" might have a high TF-IDF score, while it would have a low score in a document about cooking.
        """)

    elif technique_option == "Word Embeddings":
        st.write("""
        #### 8. Word Embeddings
        Word embeddings represent words in a continuous vector space, capturing semantic meanings. Words with similar meanings have similar vector representations. Popular word embedding models include Word2Vec, GloVe, and FastText.
        
        - **Example**: The words "king" and "queen" are represented as vectors that are close to each other in the vector space due to their semantic similarity.
        """)

    elif technique_option == "Named Entity Recognition (NER)":
        st.write("""
        #### 9. Named Entity Recognition (NER)
        NER involves identifying and classifying named entities in text, such as people, organizations, locations, and dates. This is often used for information extraction from unstructured text.
        
        - **Example**:
          - Text: "Barack Obama was born in Hawaii."
          - Extracted Entities: `["Barack Obama" (Person), "Hawaii" (Location)]`
        """)

    elif technique_option == "Part-of-Speech (POS) Tagging":
        st.write("""
        #### 10. Part-of-Speech (POS) Tagging
        POS tagging assigns grammatical labels to words in a sentence, such as noun (NN), verb (VB), or adjective (JJ). This helps understand the syntactic structure of the sentence.
        
        - **Example**:
          - Sentence: "The cat sat on the mat."
          - POS Tags: `[("The", "DT"), ("cat", "NN"), ("sat", "VBD"), ("on", "IN"), ("the", "DT"), ("mat", "NN")]`
        """)

    elif technique_option == "Sentiment Analysis":
        st.write("""
        #### 11. Sentiment Analysis
        Sentiment analysis involves determining the sentiment of a text, often classifying it as positive, negative, or neutral. It is commonly used for analyzing customer feedback, social media posts, and product reviews.
        
        - **Example**: 
          - Text: "I love this product!"
          - Sentiment: Positive
          
        Sentiment analysis helps businesses and organizations understand public perception and customer satisfaction.
        """)