NeonSamurai commited on
Commit
5748a3a
Β·
verified Β·
1 Parent(s): fffaeca

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +153 -18
app.py CHANGED
@@ -1,26 +1,161 @@
 
 
 
 
1
  import streamlit as st
 
 
 
2
 
3
- st.title("Welcome to the NLP Platform")
4
- st.write("""
5
- Explore the exciting field of Natural Language Processing (NLP).
6
- Whether you're just beginning your journey or you're an expert in the field, this platform offers comprehensive resources to help you gain a deeper understanding of how machines process and interpret human language.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  """)
8
 
9
- st.header("Who Should Use This Application?")
10
- st.write("""
11
- This platform is intended for a wide audience, including students, developers, researchers, and enthusiasts interested in Natural Language Processing (NLP).
12
- Whether you're new to the field or aiming to enhance your existing knowledge, you'll find valuable insights, practical guides, and use cases to help you master NLP concepts and techniques.
 
 
 
 
 
13
  """)
14
 
15
- st.header("What Will You Learn?")
16
- st.write("""
17
- This application serves as an educational resource, providing users with a structured approach to understanding the core principles of NLP.
18
- It covers a range of topics, including:
19
- - Sentiment analysis
20
- - Text classification
21
- - Machine translation
22
- - Named entity recognition (NER)
23
- - And more...
 
 
 
24
 
25
- You will gain hands-on experience with NLP models, from building and training to applying them in real-world scenarios. This platform is designed to bridge the gap between theory and practice, empowering you to apply NLP techniques effectively in your projects.
 
 
 
 
 
26
  """)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+ import nltk
3
+ from nltk.corpus import stopwords
4
+ from nltk.tokenize import word_tokenize
5
  import streamlit as st
6
+ import base64
7
+ import string
8
+ from facts import show_fun_fact
9
 
10
+ # Download necessary resources
11
+ #nltk.download('punkt')
12
+ #nltk.download('stopwords')
13
+
14
+ # Set Streamlit page config
15
+ st.set_page_config(layout="centered")
16
+
17
+
18
+ # Encode image for the title
19
+ def encode_image(image_path):
20
+ with open(image_path, "rb") as image_file:
21
+ return base64.b64encode(image_file.read()).decode()
22
+
23
+ def add_bg_from_local(image_file):
24
+ encoded_string = encode_image(image_file)
25
+ st.markdown(
26
+ f"""
27
+ <style>
28
+ .stApp {{
29
+ background-image: url(data:image/{"png"};base64,{encoded_string});
30
+ background-size: cover;
31
+ background-repeat: no-repeat;
32
+ background-attachment: fixed;
33
+ }}
34
+ </style>
35
+ """,
36
+ unsafe_allow_html=True
37
+ )
38
+
39
+ # Set the background image
40
+ add_bg_from_local("Images/backgroud.jpg")
41
+
42
+ file_ = open("Images/title-icon-unscreen.gif", "rb").read()
43
+ base64_gif = base64.b64encode(file_).decode("utf-8")
44
+
45
+ st.markdown(
46
+ f"""
47
+ <h1 style='text-align: center; color: white;'>
48
+ Natural Language Processing
49
+ <img src="data:image/gif;base64,{base64_gif}" alt="Icon" style="width: 85px; margin-right: 10px;">
50
+ </h1>
51
+ """,
52
+ unsafe_allow_html=True
53
+ )
54
+
55
+ title_image_base64 = encode_image(r"Images/NLP_title_img.jpg")
56
+ st.image("Images/NLP_title_img.jpg", caption="Unlocking the power of language with NLP", use_column_width=True)
57
+
58
+ # Introduction section with emojis and styled text
59
+ st.markdown("<h2 style='text-align: center; color: white;'>What You'll Discover Here πŸ•΅οΈβ€β™‚οΈ</h2>", unsafe_allow_html=True)
60
+
61
+ st.markdown("""
62
+ - 🌐 **Introduction to NLP**: Learn the fundamentals of how machines understand human language.
63
+ - πŸ› οΈ **Life Cycle of NLP Projects**: Understand the step-by-step process of building NLP solutions.
64
  """)
65
 
66
+ st.markdown("<h2 style='text-align: center; color: white;'> Why NLP Matters? 🌍</h2>", unsafe_allow_html=True)
67
+ st.markdown("""
68
+ From understanding human emotions to powering search engines, Natural Language Processing (NLP) is everywhere.
69
+ Some real-world applications include:
70
+ - Chatbots and virtual assistants (e.g., Siri, Alexa).
71
+ - Sentiment analysis in social media.
72
+ - Language translation (e.g., Google Translate).
73
+ - Text summarization for news and articles.
74
+ - Personalized recommendations.
75
  """)
76
 
77
+ st.markdown("<h2 style='text-align: center; color: white;'> Try It Yourself! πŸ§‘β€πŸ”¬</h2>", unsafe_allow_html=True)
78
+ user_input = st.text_area("Enter any text to see how it's processed:", "Natural Language Processing is amazing!")
79
+
80
+ if user_input:
81
+ # Tokenization
82
+ tokens = word_tokenize(user_input)
83
+ st.write("### Tokens:")
84
+ st.write(tokens)
85
+
86
+ # Stopword and punctuation removal
87
+ stop_words = set(stopwords.words("english"))
88
+ cleaned_tokens = [word for word in tokens if word.lower() not in stop_words and word not in string.punctuation]
89
 
90
+ st.write("### After Removing Stopwords and Punctuation:")
91
+ st.write(cleaned_tokens)
92
+
93
+ st.markdown("## Ready to Get Started with NLP? πŸš€")
94
+ st.markdown("""
95
+ Let’s get started and explore the exciting Introduction to NLP! 🌟
96
  """)
97
+
98
+ show_fun_fact()
99
+
100
+ # Credir Section
101
+ st.markdown("""
102
+ <style>
103
+ .footer {
104
+ width: 100%;
105
+ text-align: center;
106
+ color: white;
107
+ padding: 20px 0;
108
+ background: linear-gradient(135deg, #f36f6f, #FF7F50); /* Gradient background */
109
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); /* Adds shadow for a 3D effect */
110
+ margin-top: 50px;
111
+ border-radius: 10px 10px 0 0; /* Rounded corners */
112
+ }
113
+
114
+ .footer p {
115
+ font-size: 18px;
116
+ font-weight: bold;
117
+ }
118
+
119
+ .footer a {
120
+ color: white;
121
+ text-decoration: none;
122
+ margin: 0 10px;
123
+ transition: transform 0.3s ease, scale 0.2s;
124
+ }
125
+
126
+ .footer a:hover {
127
+ transform: scale(1.2);
128
+ transition: transform 0.3s ease;
129
+ }
130
+
131
+ .footer img {
132
+ margin-left: 8px;
133
+ }
134
+
135
+ .footer a:active {
136
+ transform: scale(1);
137
+ }
138
+
139
+ .footer span {
140
+ font-size: 14px;
141
+ display: block;
142
+ margin-top: 8px;
143
+ }
144
+
145
+ .footer .icons {
146
+ margin-top: 15px;
147
+ }
148
+ </style>
149
+
150
+ <div class="footer">
151
+ <p>Created with πŸ’‘ by Aamer
152
+ <a href='https://linkedin.com/mohd-suhaib-aamer' target='_blank'>
153
+ <img src='https://img.icons8.com/fluent/48/000000/linkedin.png' width='24' height='24'/>
154
+ </a>
155
+ <a href='https://github.com/Suhaib-Aamer' target='_blank'>
156
+ <img src='https://img.icons8.com/fluent/48/000000/github.png' width='24' height='24'/>
157
+ </a>
158
+ </p>
159
+ <span>Thank you for exploring NLP with me!</span>
160
+ </div>
161
+ """, unsafe_allow_html=True)