trohith89 commited on
Commit
f04a4d6
·
verified ·
1 Parent(s): e1ffa0a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +302 -136
app.py CHANGED
@@ -1,138 +1,304 @@
1
  import streamlit as st
2
 
3
-
4
- st.header("Introduction to Natural Language Processing (NLP)")
5
- st.markdown("<p>Natural Language Processing (NLP) is a subfield of Artificial Intelligence (AI) that focuses on the interaction between computers and human language. The goal of NLP is to enable machines to understand, interpret, and generate human language in a way that is valuable and meaningful.</p>",unsafe_allow_html= True)
6
-
7
-
8
- st.subheader("What is NLP?")
9
- st.markdown("<p>Natural language processing (NLP) is a field of computer science and a subfield of artificial intelligence that aims to make computers understand human language. NLP uses computational linguistics, which is the study of how language works, and various models based on statistics, machine learning, and deep learning. These technologies allow computers to analyze and process text or voice data, and to grasp their full meaning, including the speaker’s or writer’s intentions and emotions. </p>",unsafe_allow_html= True)
10
- st.image("NLP.jpg")
11
- st.markdown("<p>NLP powers many applications that use language, such as text translation, voice recognition, text summarization, and chatbots. You may have used some of these applications yourself, such as voice-operated GPS systems, digital assistants, speech-to-text software, and customer service bots. NLP also helps businesses improve their efficiency, productivity, and performance by simplifying complex tasks that involve language. </p>",unsafe_allow_html= True)
12
-
13
-
14
- st.subheader("NLP Techniques")
15
- st.markdown("<p>NLP encompasses a wide array of techniques that aimed at enabling computers to process and understand human language. These tasks can be categorized into several broad areas, each addressing different aspects of language processing. Here are some of the key NLP techniques:</p>",unsafe_allow_html= True)
16
-
17
- st.markdown('<p style="color:;"><b>1. Text Processing and Preprocessing In NLP</b></p>', unsafe_allow_html=True)
18
- st.write("Before performing any analysis or modeling, raw text data must be cleaned and prepared.")
19
- st.markdown('<p style="color:;"><b>a. Tokenization</b></p>', unsafe_allow_html=True)
20
- st.write("Splits text into smaller units like words or sentences.")
21
- st.write("**Types:**")
22
-
23
- st.write("**(i) Word Tokenization:** Breaking text into words.")
24
- st.write("Example: _'I love NLP'_ [‘I’, ‘love’, ‘NLP’]")
25
-
26
- st.write("**(ii) Sentence Tokenization:** Breaking text into sentences.")
27
- st.write("Example: _'I love NLP. It’s fascinating!'_ → [‘I love NLP.’, ‘It’s fascinating!’]")
28
-
29
- st.markdown('<p style="color:;"><b>b. Stopword Removal</b></p>', unsafe_allow_html=True)
30
- st.write("Removes common words like “the,” “and,” “is that do not contribute much to analysis.")
31
-
32
-
33
- st.markdown('<p style="color:;"><b>c. Stemming and Lemmatization</b></p>', unsafe_allow_html=True)
34
- st.write("Stemming: Reduces words to their base or root form by chopping off suffixes (may not produce valid words).")
35
- st.write("Example: _“running” _ → “run”")
36
-
37
- st.write("Lemmatization: Converts words to their base form using vocabulary and grammar")
38
- st.write("Example: _“good” _ “better”")
39
-
40
- st.markdown('<p style="color:;"><b>d. Part-of-Speech (POS) Tagging</b></p>', unsafe_allow_html=True)
41
- st.write("Labels words with their grammatical roles (noun, verb, adjective, etc.)")
42
- st.write("Example: _The cat sleeps”_ [“The/DET”, “cat/NOUN”, “sleeps/VERB”]")
43
-
44
- st.markdown('<p style="color:;"><b>e. Named Entity Recognition (NER)</b></p>', unsafe_allow_html=True)
45
- st.write("Identifies and classifies entities in text (e.g., names, dates, locations)")
46
- st.write("Example: _ “Barack Obama was born in Hawaii. _ [Barack Obama: PERSON, Hawaii: LOCATION]")
47
-
48
-
49
- st.markdown('<p style="color:;"><b>f. Text Normalization</b></p>', unsafe_allow_html=True)
50
- st.write("Converts text to a standard format (lowercasing, removing punctuation, etc.).")
51
-
52
-
53
- st.markdown('<p style="color:;"><b>2. Feature Extraction Techniques</b></p>', unsafe_allow_html=True)
54
- st.write("Text needs to be transformed into numerical representations for machine learning models.")
55
-
56
- st.markdown('<p style="color:;"><b>a. Bag of Words (BoW)</b></p>', unsafe_allow_html=True)
57
- st.write("Represents text as a vector of word frequencies or occurrences, ignoring grammar and order")
58
- st.write("Examples:")
59
- st.write("Text: “I love NLP” and “NLP is great”")
60
- st.write("Vocabulary: [“I”, “love”, “NLP”, “is”, “great”]")
61
- st.write("Vector for “I love NLP”: [1, 1, 1, 0, 0]")
62
-
63
-
64
- st.markdown('<p style="color:;"><b>b. Term Frequency-Inverse Document Frequency (TF-IDF)</b></p>', unsafe_allow_html=True)
65
- st.write("The **TF-IDF Vectorizer** is a popular technique in Natural Language Processing (NLP) used to convert text into numerical values that can be used by machine learning models. It stands for Term Frequency-Inverse Document Frequency and helps highlight the importance of words in a document relative to a collection of documents (called a corpus).")
66
-
67
- st.write('**Term Frequency (TF)** \n - Measures how often a word appears in a single document. \n - Formula: \n _TF_ = Number of times the word appears in the document / Total number of words in the document' )
68
- st.write('**Inverse Document Frequency (IDF)** \n Measures how unique or rare a word is across all documents in the corpus. \n - Formula: \n _IDF_ = log(Total no.of documents / No of Documnets containing the word) \n Words that appear in many documents (like "the" or "and") will have a low IDF value, while unique words (like "NLP") will have a higher IDF.')
69
- st.write('**TF - IDF Score:** \n - Combines TF and IDF to calculate the importance of a word in a document. \n - Formula: \n _TF - IDF = TF x IDF_ \n Words that are frequent in a document but rare in the overall corpus get a higher score.')
70
-
71
- st.write("""
72
- **Example**
73
- **Consider these two documents:**
74
-
75
- - "I love NLP"
76
- - "NLP is amazing"
77
-
78
- **Step 1: Calculate TF**
79
- - "NLP" appears once in each document, so its TF is **1/3** in both.
80
- - Words like "love" and "amazing" also have a TF of **1/3**.
81
-
82
- **Step 2: Calculate IDF**
83
- - "NLP" appears in both documents, so its IDF is **log(2/2) = 0**.
84
- - "love" and "amazing" appear in only one document each, so their IDF is **log(2/1) = 0.69**.
85
-
86
- **Step 3: Compute TF-IDF**
87
- - "NLP" gets a TF-IDF score of **1/3 × 0 = 0** (not unique).
88
- - "love" and "amazing" get scores of **1/3 × 0.69 = 0.23** (more unique).
89
- """)
90
-
91
-
92
- st.markdown('<p style="color:;"><b>c. Word Embeddings</b></p>', unsafe_allow_html=True)
93
- st.write("Word embeddings are a type of representation for text where words are converted into dense numerical vectors. These vectors capture the semantic meaning of words and their relationships with other words in a way that computers can understand.")
94
-
95
-
96
- st.write("""
97
- **Word Embedding Techniques**
98
-
99
- **1. Word2Vec**
100
- Developed by Google, it uses two main approaches:
101
- - **CBOW (Continuous Bag of Words):** Predicts a word based on its context.
102
- - **Skip-Gram:** Predicts the context given a word.
103
-
104
- **2. GloVe (Global Vectors)**
105
- Developed by Stanford, it captures word relationships by analyzing co-occurrence statistics of words in a large corpus.
106
-
107
- **3. FastText**
108
- Developed by Facebook, it extends Word2Vec by considering subword information, making it better at handling rare and misspelled words.
109
-
110
- **4. Transformers (Contextual Embeddings)**
111
- Models like **BERT**, **ELMo**, and **GPT** generate embeddings based on the context in which a word appears, capturing nuanced meanings.
112
- """)
113
-
114
- st.subheader("Future of NLP")
115
- st.write("""
116
- The future of Natural Language Processing (NLP) is exciting, with advancements that aim to make machines understand and interact with human language more effectively. Here are key areas shaping the future of NLP: \n
117
- **1.Context-Aware Models:**
118
- - Enhanced Understanding of Context: Models like GPT and BERT have already revolutionized NLP. Future advancements will further refine their ability to comprehend nuanced context, sarcasm, and idioms.
119
-
120
- **2.Real-Time Multilingual NLP**
121
- - Instant Translations: Real-time and accurate translation across diverse languages, including low-resource ones.
122
- - Language Independence: NLP systems capable of handling any language seamlessly.
123
-
124
- **3.Conversational AI**
125
- - Human-like Conversations: Chatbots and virtual assistants will become more natural, empathetic, and intuitive in conversations.
126
- - Emotion Recognition: Understanding and responding to user emotions effectively.
127
-
128
- **4. Zero-shot and Few-shot Learning**
129
- - Minimal Data Requirement: Models will handle new tasks or languages with little to no additional training, making NLP accessible across domains with limited data.
130
-
131
- **5. Multimodal Learning**
132
- - Beyond Text: Integrating text with images, audio, and video for richer applications like understanding memes, videos, or interactive media.
133
-
134
- The future of NLP is about creating systems that communicate more naturally, inclusively, and intelligently, enabling transformative applications in every aspect of life.
135
-
136
- """)
137
-
138
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
 
3
+ # Sidebar for navigation
4
+ sidebar = st.sidebar
5
+
6
+ # Sidebar header
7
+ sidebar.header('🌐 NLP Navigation')
8
+
9
+ # Sidebar options for NLP Overview, Lifecycle, and Techniques
10
+ sidebar_option = sidebar.radio('Choose a section to explore:', ['What is NLP?', 'NLP Lifecycle', 'NLP Techniques'])
11
+
12
+ # Store the selected page in session state
13
+ if 'selected_page' not in st.session_state:
14
+ st.session_state.selected_page = sidebar_option
15
+
16
+ # Update the selected page if the user selects a different option
17
+ if sidebar_option != st.session_state.selected_page:
18
+ st.session_state.selected_page = sidebar_option
19
+
20
+ # Dynamically update the title based on the selected option
21
+ if st.session_state.selected_page == 'What is NLP?':
22
+ st.title('🤖 What is Natural Language Processing (NLP)?')
23
+ elif st.session_state.selected_page == 'NLP Lifecycle':
24
+ st.title('🔄 Natural Language Processing (NLP) Lifecycle')
25
+ if sidebar_option == 'Problem Definition':
26
+ st.title('🔧 Steps in the Natural Language Processing (NLP) lifecycle:')
27
+ elif st.session_state.selected_page == 'NLP Techniques':
28
+ st.title('⚙️ Techniques in Natural Language Processing (NLP)')
29
+
30
+ # Content for "What is NLP?"
31
+ if st.session_state.selected_page == 'What is NLP?':
32
+ st.write("""
33
+ ### 🤖 What is NLP?
34
+ Natural Language Processing (NLP) is a subfield of artificial intelligence (AI) that focuses on the interaction between computers and human (natural) languages. The goal of NLP is to enable machines to understand, interpret, and generate human language in a way that is meaningful.
35
+
36
+ NLP is essential for enabling computers to process and analyze large amounts of natural language data, such as:
37
+ - 📜 Text from documents
38
+ - 🗣️ Speech from conversations
39
+ - 🖼️ Images with textual descriptions
40
+ #### Key Components of NLP:
41
+ - **Syntax**: Refers to the arrangement of words in a sentence.
42
+ - **Semantics**: Focuses on the meaning of the words and sentences.
43
+ - **Pragmatics**: Involves the context and intent behind language.
44
+ - **Discourse**: Studies how previous sentences and context influence meaning.
45
+ #### Example Applications of NLP:
46
+ - **Machine Translation**: Automatic translation of text from one language to another (e.g., Google Translate).
47
+ - **Speech Recognition**: Converting spoken language into text (e.g., Siri, Alexa).
48
+ - **Sentiment Analysis**: Analyzing text to determine the sentiment (positive, negative, neutral) (e.g., analyzing customer reviews).
49
+ - **Text Summarization**: Creating a short summary of a long text (e.g., summarizing articles).
50
+ NLP is used across multiple domains like healthcare, finance, and customer service to automate and improve various tasks.
51
+ """)
52
+
53
+ # Content for NLP Lifecycle
54
+ elif st.session_state.selected_page == "NLP Lifecycle":
55
+ lifecycle_option = sidebar.radio("Select NLP Lifecycle Step:", [
56
+ "Overview of the NLP Life Cycle",
57
+ "Problem Definition",
58
+ "Data Collection",
59
+ "Text Preprocessing",
60
+ "Text Representation",
61
+ "Model Training",
62
+ "Evaluation",
63
+ "Deployment"
64
+ ])
65
+
66
+ if lifecycle_option == "Overview of the NLP Life Cycle":
67
+ st.write("""
68
+ #### 🔄 Overview of the NLP Life Cycle
69
+ The NLP life cycle is a structured process for building, using, and maintaining systems that work with human language. It turns unstructured text into meaningful insights or automated actions. This process ensures continuous improvement and adapts to real-world needs.
70
+
71
+ - **How It Flows**:
72
+ - The process starts with identifying the problem and collecting the required text data.
73
+ - Then, the data is cleaned and prepared for analysis.
74
+ - Models are built and tested before being deployed for use.
75
+ - Regular checks and updates ensure the solution keeps working well.
76
+
77
+ - **Flexible and Adaptive**:
78
+ - Since languages and data change (e.g., new words, trends), the process is repeated as needed.
79
+ - Models may need updates or retraining to stay accurate.
80
+
81
+ - **Combines Different Fields**:
82
+ - The process involves skills from language studies, programming, and data analysis to make sure language is understood effectively.
83
+
84
+ - **Designed for Practical Use**:
85
+ - The goal is to create solutions that can handle tasks like analyzing text, identifying emotions, powering chatbots, or translating languages accurately and efficiently.
86
+
87
+ - **Key Challenges Solved**:
88
+ - Managing the complexity of language (e.g., meaning, structure).
89
+ - Working with large and messy datasets.
90
+ - Handling multiple languages and specific industries.
91
+ - Ensuring solutions are fast and efficient.
92
+
93
+ #### Steps in the NLP Life Cycle:
94
+ 1. Problem Definition
95
+ 2. Data Collection
96
+ 3. Data Preprocessing
97
+ 4. Feature Engineering
98
+ 5. Model Selection and Training
99
+ 6. Model Evaluation
100
+ 7. Model Tuning
101
+ 8. Deployment
102
+ 9. Monitoring and Maintenance
103
+ """)
104
+
105
+ elif lifecycle_option == "Problem Definition":
106
+ st.write("""
107
+ #### 🔧 1. Problem Definition
108
+ - The first step in the NLP lifecycle is defining the problem. This means understanding the goal and figuring out how NLP can help solve the problem.
109
+ - Based on the problem, you will need to gather the data.
110
+ - **To better understand the problem, consider asking questions such as**:
111
+ - 🎯 What is the main goal of this analysis?
112
+ - 📝 What kind of text data are we working with (e.g., reviews, social media posts, documents)?
113
+ - 📊 What do we want the output to be (e.g., sentiment score, summary, or classification)?
114
+
115
+ **Example of a problem statement**: The goal could be to classify customer reviews as either positive or negative, or to find the main topics in product reviews.
116
+ """)
117
+
118
+ elif lifecycle_option == "Data Collection":
119
+ st.write("""
120
+ #### 2. Data Collection
121
+ Data collection is the second step in the NLP lifecycle. It involves gathering data from various sources based on the problem statement, so it can be analyzed and processed.
122
+ - **Sources for data collection**:
123
+ - 📚 The data should be collected based on a clear understanding of the problem statement.
124
+ - 🌐 From datasets available on websites like Kaggle.
125
+ - 🔌 Through APIs.
126
+ - 🕸️ Web scraping can also be used to gather data from websites using tools like Selenium or BeautifulSoup.
127
+ - ✋ Manually, when needed.
128
+ - In most cases, data is collected from websites, APIs, or through web scraping. However, manual collection may be necessary in rare cases.
129
+ **Example**: Scraping customer reviews from Amazon to analyze sentiment and feedback about a product.
130
+ """)
131
+
132
+ elif lifecycle_option == "Text Preprocessing":
133
+ st.write("""
134
+ #### 🧹 3. Text Preprocessing
135
+ Text preprocessing prepares raw text for further analysis. This stage involves cleaning and transforming the data into a structured format that machine learning models can understand.
136
+ - **Tokenization**: Splitting text into smaller units (e.g., words, phrases).
137
+ - **Stop Words Removal**: Removing common words that don’t contribute much information.
138
+ - **Lemmatization**: Converting words into their base or dictionary form.
139
+ - **Stemming**: Cutting off prefixes or suffixes from words.
140
+ - **Lowercasing**: Converting all characters in the text to lowercase.
141
+ **Example**: For the sentence "The quick brown fox is running fast", after preprocessing:
142
+ - Tokenization: ["The", "quick", "brown", "fox", "is", "running", "fast"]
143
+ - Stop Words Removal: ["quick", "brown", "fox", "running", "fast"]
144
+ - Lemmatization: ["quick", "brown", "fox", "run", "fast"]
145
+ """)
146
+
147
+ elif lifecycle_option == "Text Representation":
148
+ st.write("""
149
+ #### 📝 4. Text Representation
150
+ After preprocessing, the text data needs to be converted into a numerical format for use in machine learning models. There are several methods for text representation:
151
+ - **Bag of Words (BoW)**: Converts text into a matrix of word frequencies.
152
+ - **TF-IDF**: Weighs words based on their frequency in a specific document relative to their frequency across the entire dataset.
153
+ - **Word Embeddings**: Transforms words into dense vectors that capture semantic meaning.
154
+ **Example**: Using BoW to convert the sentence "I love NLP" into a vector representation:
155
+ - Vocabulary: ["I", "love", "NLP"]
156
+ - Vector: [1, 1, 1] (word frequency representation)
157
+ """)
158
+
159
+ elif lifecycle_option == "Model Training":
160
+ st.write("""
161
+ #### 🏋️‍♂️ 5. Model Training
162
+ In the model training stage, machine learning algorithms are trained on the preprocessed and represented text data. The choice of model depends on the task:
163
+ - **Text Classification**: Naive Bayes, Support Vector Machines (SVM), or neural networks.
164
+ - **Named Entity Recognition (NER)**: Conditional Random Fields (CRF), LSTMs, or transformers.
165
+ - **Sentiment Analysis**: Logistic regression, Naive Bayes, or transformer-based models like BERT.
166
+ **Example**: Training a Naive Bayes classifier to categorize news articles into topics such as "Sports", "Politics", etc.
167
+ """)
168
+
169
+ elif lifecycle_option == "Evaluation":
170
+ st.write("""
171
+ #### 🏅 6. Evaluation
172
+ After training the model, it's important to evaluate its performance using metrics such as accuracy, precision, recall, and F1-score.
173
+ - **Accuracy**: The percentage of correct predictions.
174
+ - **Precision**: The percentage of relevant instances among the retrieved instances.
175
+ - **Recall**: The percentage of relevant instances that were retrieved.
176
+ - **F1-score**: The harmonic mean of precision and recall.
177
+
178
+ **Example**: If a sentiment analysis model predicts positive sentiment in 80 out of 100 reviews, its accuracy is 80%.
179
+ """)
180
+
181
+ elif lifecycle_option == "Deployment":
182
+ st.write("""
183
+ #### 🚀 7. Deployment
184
+ The final step is deploying the model for real-time use. This involves integrating it into a system or application where it can process live data.
185
+ - **Real-time Applications**: Chatbots, sentiment analysis for social media monitoring, text summarization for news.
186
+ - **Maintenance**: Continuously monitor the model to ensure its performance remains high. Updates might be necessary if the language evolves or new data emerges.
187
+
188
+ **Example**: Deploying a chatbot to answer customer inquiries based on historical support tickets.
189
+ """)
190
+
191
+ # Content for NLP Techniques
192
+
193
+
194
+
195
+ # Content for "NLP Techniques"
196
+ elif st.session_state.selected_page == "NLP Techniques":
197
+ technique_option = sidebar.radio("Select NLP Technique:", [
198
+ "NLP Techniques",
199
+ "Tokenization",
200
+ "Stop Words Removal",
201
+ "Lemmatization",
202
+ "Stemming",
203
+ "Bag of Words (BoW)",
204
+ "TF-IDF",
205
+ "Word Embeddings",
206
+ "Named Entity Recognition (NER)",
207
+ "Part-of-Speech (POS) Tagging",
208
+ "Sentiment Analysis"
209
+ ])
210
+ if technique_option == "NLP Techniques":
211
+ st.write("""
212
+ ### ⚙️ Techniques in NLP
213
+ NLP uses a variety of techniques to process and analyze text data. Some of the most common techniques include:
214
+
215
+ 1. **Tokenization**: Breaking down text into smaller units (e.g., words, sentences).
216
+ 2. **Part-of-Speech (POS) Tagging**: Identifying the grammatical roles of words in a sentence (e.g., noun, verb, adjective).
217
+ 3. **Named Entity Recognition (NER)**: Identifying entities such as names, dates, locations, etc.
218
+ 4. **Dependency Parsing**: Analyzing the syntactic structure of sentences.
219
+ 5. **Sentiment Analysis**: Analyzing the sentiment of text (positive, negative, neutral).
220
+ 6. **Word Embeddings**: Representing words as vectors in a continuous space (e.g., Word2Vec, GloVe).
221
+
222
+ **Example**: Sentiment analysis can be used to identify whether customer reviews are positive, negative, or neutral based on the words used in the text.
223
+ """)
224
+
225
+
226
+ elif technique_option == "Tokenization":
227
+ st.write("""
228
+ #### 1. Tokenization
229
+ Tokenization is the process of splitting text into smaller units, such as words, sentences, or subwords. This is a key preprocessing step for many NLP tasks.
230
+ - **Example**:
231
+ - Sentence: "Natural Language Processing is awesome!"
232
+ - Tokenized words: ["Natural", "Language", "Processing", "is", "awesome"]
233
+ """)
234
+
235
+ elif technique_option == "Stop Words Removal":
236
+ st.write("""
237
+ #### 2. Stop Words Removal
238
+ Stop words are commonly used words like "the", "is", "at", etc., that do not carry much information in many NLP tasks. Removing stop words helps reduce the dimensionality and noise in the data.
239
+ - **Example**: Removing "is" from the sentence "NLP is amazing!"
240
+ """)
241
+
242
+ elif technique_option == "Lemmatization":
243
+ st.write("""
244
+ #### 3. Lemmatization
245
+ Lemmatization is the process of converting words into their root or base form based on context. It is more sophisticated than stemming, as it considers the meaning of words.
246
+ - **Example**: "better" → "good", "running" → "run".
247
+ """)
248
+
249
+ elif technique_option == "Stemming":
250
+ st.write("""
251
+ #### 4. Stemming
252
+ Stemming is the process of reducing words to their root form by removing prefixes or suffixes. This technique may result in non-dictionary words.
253
+ - **Example**: "running" → "run", "happiness" → "happi".
254
+ """)
255
+
256
+ elif technique_option == "Bag of Words (BoW)":
257
+ st.write("""
258
+ #### 5. Bag of Words (BoW)
259
+ The Bag of Words model represents text as a set of individual words, disregarding grammar and word order but keeping multiplicity. It is a simple and widely used method for text representation.
260
+ - **Example**:
261
+ - Text: "I love NLP"
262
+ - BoW: {"I": 1, "love": 1, "NLP": 1}
263
+ """)
264
+
265
+ elif technique_option == "TF-IDF":
266
+ st.write("""
267
+ #### 6. TF-IDF (Term Frequency-Inverse Document Frequency)
268
+ TF-IDF helps determine the importance of a word in a document relative to the entire dataset. It reduces the weight of common words and increases the weight of rare but important words.
269
+ - **Example**: The word "data" might have a high TF-IDF score in a document about data analysis but a low score in a document about cooking.
270
+ """)
271
+
272
+ elif technique_option == "Word Embeddings":
273
+ st.write("""
274
+ #### 7. Word Embeddings
275
+ Word embeddings are vector representations of words that capture semantic relationships. Words with similar meanings have similar vectors. Common word embedding models include:
276
+ - **Word2Vec**
277
+ - **GloVe**
278
+ - **FastText**
279
+ **Example**: The words "king" and "queen" would have similar vector representations because they share semantic relationships.
280
+ """)
281
+
282
+ elif technique_option == "Named Entity Recognition (NER)":
283
+ st.write("""
284
+ #### 8. Named Entity Recognition (NER)
285
+ NER is the task of identifying named entities such as persons, organizations, locations, and dates in text. This technique is commonly used for information extraction.
286
+ - **Example**: "Barack Obama was born in Hawaii."
287
+ - Entities: ["Barack Obama" (Person), "Hawaii" (Location)]
288
+ """)
289
+
290
+ elif technique_option == "Part-of-Speech (POS) Tagging":
291
+ st.write("""
292
+ #### 9. Part-of-Speech (POS) Tagging
293
+ POS tagging involves assigning grammatical labels (such as noun, verb, adjective) to each word in a sentence.
294
+ - **Example**: "The cat sat on the mat."
295
+ - POS Tags: [("The", "DT"), ("cat", "NN"), ("sat", "VBD"), ("on", "IN"), ("the", "DT"), ("mat", "NN")]
296
+ """)
297
+
298
+ elif technique_option == "Sentiment Analysis":
299
+ st.write("""
300
+ #### 10. Sentiment Analysis
301
+ Sentiment analysis involves determining the sentiment of a piece of text, typically categorizing it as positive, negative, or neutral. This is commonly used for customer feedback and social media monitoring.
302
+ - **Example**: "I love this product!" → Positive Sentiment
303
+ """)
304
+