Sathwikchowdary/Natural_Language_Processing
0
1import streamlit as st2import base643import webbrowser4 5# Custom styles6st.markdown(7 """8 <style>9 .stApp {10 background-color: #f0f8ff;11 }12 .title {13 text-align: center;14 color: black;15 font-size: 40px;16 font-family: 'Arial', sans-serif;17 font-weight: bold;18 }19 .header {20 font-size: 30px;21 font-family: 'Arial', sans-serif;22 color: black;23 font-style: italic;24 font-weight: bold;25 }26 .header1 {27 font-size: 22px;28 font-family: 'Arial', sans-serif;29 color: black;30 font-weight: bold;31 }32 .header2 {33 font-size: 20px;34 font-family: 'Arial', sans-serif;35 color: black;36 font-weight: bold;37 text-decoration: underline;38 }39 .content {40 font-size: 18px;41 font-family: 'Arial', sans-serif;42 line-height: 1.8;43 color: #1e90ff; /* Blue color for text */44 }45 .example {46 font-size: 18px;47 font-family: 'Arial', sans-serif;48 font-style: italic;49 color: #1e90ff; /* Blue color for examples */50 }51 </style>52 """,53 unsafe_allow_html=True,54)55 56# Main content of the page57st.markdown("<div class='title'>Understanding Natural Language Processing (NLP) 🗣️</div><br>", unsafe_allow_html=True)58 59# Introduction to NLP60st.markdown("<div class='header'>Introduction to NLP</div><br>", unsafe_allow_html=True)61st.markdown("<div class='content'>Natural Language Processing (NLP) is a branch of Artificial Intelligence (AI) that enables machines to interpret, analyze, and respond to human languages effectively.</div><br>", unsafe_allow_html=True)62 63# Key Terminology in NLP64st.markdown("<div class='header'>Key Terminology in NLP</div><br>", unsafe_allow_html=True)65 66terms = [67 ("Corpus", "A structured collection of texts used for analysis."),68 ("Document", "A single unit within a corpus, such as a sentence, paragraph, or entire article."),69 ("Paragraph", "A cohesive collection of sentences forming a unit of meaning."),70 ("Sentence", "A collection of words forming a complete thought."),71 ("Word", "A meaningful unit of language consisting of characters."),72 ("Character", "The smallest unit of language, including letters, numbers, and symbols."),73 ("Tokenization", "The process of breaking down text into smaller units called tokens."),74]75 76for term, description in terms:77 st.markdown(f"<div class='header1'>{term}</div><br>", unsafe_allow_html=True)78 st.markdown(f"<div class='content'>{description}</div><br>", unsafe_allow_html=True)79 80# Tokenization Types81st.markdown("<div class='header1'>Types of Tokenization</div><br>", unsafe_allow_html=True)82 83# Sentence Tokenization84st.markdown("<div class='header2'>1. Sentence Tokenization</div><br>", unsafe_allow_html=True)85st.markdown("<div class='content'>This involves breaking a document into individual sentences.</div><br>", unsafe_allow_html=True)86st.markdown("""87 <div class="example"> 88 Example:<br>89 Document: I love pizza. I love burgers. I love pasta.<br>90 Tokens: [ "I love pizza.", "I love burgers.", "I love pasta."] 91 </div><br>92""", unsafe_allow_html=True)93 94# Word Tokenization95st.markdown("<div class='header2'>2. Word Tokenization</div><br>", unsafe_allow_html=True)96st.markdown("<div class='content'>This involves splitting sentences into individual words.</div><br>", unsafe_allow_html=True)97st.markdown("""98 <div class="example"> 99 Example:<br>100 Sentence: I love pizza.<br>101 Tokens: [ "I", "love", "pizza" ] 102 </div><br>103""", unsafe_allow_html=True)104 105# Character Tokenization106st.markdown("<div class='header2'>3. Character Tokenization</div><br>", unsafe_allow_html=True)107st.markdown("<div class='content'>This involves breaking words into individual characters.</div><br>", unsafe_allow_html=True)108st.markdown("""109 <div class="example"> 110 Example:<br>111 Sentence: I love pizza.<br>112 Tokens: [ "I", "l", "o", "v", "e", "p", "i", "z", "z", "a" ] 113 </div><br>114""", unsafe_allow_html=True)115 116# Stopwords117st.markdown("<div class='header1'>Stopwords</div><br>", unsafe_allow_html=True)118st.markdown("<div class='content'>Stopwords are common words that add little meaning to sentences and can often be removed for analysis.</div><br>", unsafe_allow_html=True)119st.markdown("""120 <div class="example"> 121 Example:<br>122 Sentence: In Hyderabad, we can eat biryani.<br>123 Without stopwords: Hyderabad eat biryani.<br>124 Stopwords: [ "In", "we", "can" ]125 </div><br>126""", unsafe_allow_html=True)127 128# Vectorization129st.markdown("<div class='header1'>Vectorization</div><br>", unsafe_allow_html=True)130st.markdown("<div class='content'>Vectorization converts textual data into numerical representations for processing by machine learning models.</div><br>", unsafe_allow_html=True)131st.markdown("<div class='header1'>Types of Vectorization</div><br>", unsafe_allow_html=True)132st.markdown("""133 <div class="content"> 134 1. One-hot Encoding<br>135 2. Bag of Words (BoW)<br>136 3. Term Frequency-Inverse Document Frequency (TF-IDF)<br> 137 </div><br>138""", unsafe_allow_html=True)139 