Spaces:
Sleeping
Sleeping
File size: 4,908 Bytes
5748a3a e0c7014 5748a3a f0ef4c6 5748a3a 1e56bb4 5748a3a f0ef4c6 5748a3a 91c34a2 5748a3a e0c7014 5748a3a e0c7014 5748a3a e0c7014 5748a3a e0c7014 5748a3a 91c34a2 5748a3a |
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 |
import random
import streamlit as st
import base64
import string
from facts import show_fun_fact
import nltk
# Download necessary resources
nltk.download('punkt_tab')
nltk.download('stopwords')
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
# Set Streamlit page config
st.set_page_config(layout="centered")
# Encode image for the title
def encode_image(image_path):
with open(image_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode()
def add_bg_from_local(image_file):
encoded_string = encode_image(image_file)
st.markdown(
f"""
<style>
.stApp {{
background-image: url(data:image/{"png"};base64,{encoded_string});
background-size: cover;
background-repeat: no-repeat;
background-attachment: fixed;
}}
</style>
""",
unsafe_allow_html=True
)
# Set the background image
add_bg_from_local("Images/backgroud.jpg")
file_ = open("Images/title-icon-unscreen.gif", "rb").read()
base64_gif = base64.b64encode(file_).decode("utf-8")
st.markdown(
f"""
<h1 style='text-align: center; color: white;'>
Natural Language Processing
<img src="data:image/gif;base64,{base64_gif}" alt="Icon" style="width: 85px; margin-right: 10px;">
</h1>
""",
unsafe_allow_html=True
)
title_image_base64 = encode_image(r"Images/NLP_title_img.jpg")
st.image("Images/NLP_title_img.jpg", caption="Unlocking the power of language with NLP", use_container_width=True)
# Introduction section with emojis and styled text
st.markdown("<h2 style='text-align: center; color: white;'>What You'll Discover Here π΅οΈββοΈ</h2>", unsafe_allow_html=True)
st.markdown("""
- π **Introduction to NLP**: Learn the fundamentals of how machines understand human language.
- π οΈ **Life Cycle of NLP Projects**: Understand the step-by-step process of building NLP solutions.
""")
st.markdown("<h2 style='text-align: center; color: white;'> Why NLP Matters? π</h2>", unsafe_allow_html=True)
st.markdown("""
From understanding human emotions to powering search engines, Natural Language Processing (NLP) is everywhere.
Some real-world applications include:
- Chatbots and virtual assistants (e.g., Siri, Alexa).
- Sentiment analysis in social media.
- Language translation (e.g., Google Translate).
- Text summarization for news and articles.
- Personalized recommendations.
""")
st.markdown("<h2 style='text-align: center; color: white;'> Try It Yourself! π§βπ¬</h2>", unsafe_allow_html=True)
user_input = st.text_area("Enter any text to see how it's processed:", "Natural Language Processing is amazing!")
if user_input:
# Tokenization
tokens = word_tokenize(user_input)
st.write("### Tokens:")
st.write(tokens)
# Stopword and punctuation removal
stop_words = set(stopwords.words("english"))
cleaned_tokens = [word for word in tokens if word.lower() not in stop_words and word not in string.punctuation]
st.write("### After Removing Stopwords and Punctuation:")
st.write(cleaned_tokens)
st.markdown("## Ready to Get Started with NLP? π")
st.markdown("""
Letβs get started and explore the exciting Introduction to NLP! π
""")
# fun fact
show_fun_fact()
# Credir Section
st.markdown("""
<style>
.footer {
width: 100%;
text-align: center;
color: white;
padding: 20px 0;
background: linear-gradient(135deg, #f36f6f, #FF7F50); /* Gradient background */
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); /* Adds shadow for a 3D effect */
margin-top: 50px;
border-radius: 10px 10px 0 0; /* Rounded corners */
}
.footer p {
font-size: 18px;
font-weight: bold;
}
.footer a {
color: white;
text-decoration: none;
margin: 0 10px;
transition: transform 0.3s ease, scale 0.2s;
}
.footer a:hover {
transform: scale(1.2);
transition: transform 0.3s ease;
}
.footer img {
margin-left: 8px;
}
.footer a:active {
transform: scale(1);
}
.footer span {
font-size: 14px;
display: block;
margin-top: 8px;
}
.footer .icons {
margin-top: 15px;
}
</style>
<div class="footer">
<p>Created with π‘ by Aamer
<a href='https://linkedin.com/mohd-suhaib-aamer' target='_blank'>
<img src='https://img.icons8.com/fluent/48/000000/linkedin.png' width='24' height='24'/>
</a>
<a href='https://github.com/Suhaib-Aamer' target='_blank'>
<img src='https://img.icons8.com/fluent/48/000000/github.png' width='24' height='24'/>
</a>
</p>
<span>Thank you for exploring NLP with me!</span>
</div>
""", unsafe_allow_html=True) |