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"""
""",
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"""
Natural Language Processing
""",
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("What You'll Discover Here π΅οΈββοΈ
", 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(" Why NLP Matters? π
", 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(" Try It Yourself! π§βπ¬
", 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("""
""", unsafe_allow_html=True)