Update app.py
Browse files
app.py
CHANGED
|
@@ -3,10 +3,38 @@ import streamlit as st
|
|
| 3 |
# Apply custom styles using Streamlit's markdown
|
| 4 |
st.markdown("""
|
| 5 |
<style>
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
</style>
|
| 11 |
""", unsafe_allow_html=True)
|
| 12 |
|
|
@@ -89,64 +117,4 @@ elif selected_method == "TF-IDF":
|
|
| 89 |
|
| 90 |
**Disadvantages:**
|
| 91 |
- β Still ignores word order
|
| 92 |
-
- β Does not capture deep
|
| 93 |
-
""")
|
| 94 |
-
|
| 95 |
-
elif selected_method == "One-Hot Encoding":
|
| 96 |
-
st.markdown('<p class="sub-title">One-Hot Encoding</p>', unsafe_allow_html=True)
|
| 97 |
-
st.markdown("""
|
| 98 |
-
**Definition**: Represents words as binary vectors where each word has a unique position in a vocabulary.
|
| 99 |
-
""")
|
| 100 |
-
st.markdown("""
|
| 101 |
-
**Uses:**
|
| 102 |
-
- β
Simple NLP tasks
|
| 103 |
-
- β
Word-level feature engineering
|
| 104 |
-
|
| 105 |
-
**Advantages:**
|
| 106 |
-
- β
Simple to understand
|
| 107 |
-
- β
Works well with small vocabulary sizes
|
| 108 |
-
|
| 109 |
-
**Disadvantages:**
|
| 110 |
-
- β Inefficient for large vocabularies
|
| 111 |
-
- β No information on word meaning
|
| 112 |
-
""")
|
| 113 |
-
|
| 114 |
-
elif selected_method == "Word Embeddings (Word2Vec)":
|
| 115 |
-
st.markdown('<p class="sub-title">Word Embeddings (Word2Vec)</p>', unsafe_allow_html=True)
|
| 116 |
-
st.markdown("""
|
| 117 |
-
**Definition**: Converts words into dense numerical vectors capturing semantic relationships.
|
| 118 |
-
""")
|
| 119 |
-
st.markdown("""
|
| 120 |
-
**Uses:**
|
| 121 |
-
- β
Machine translation
|
| 122 |
-
- β
Speech recognition
|
| 123 |
-
- β
Sentiment analysis
|
| 124 |
-
|
| 125 |
-
**Advantages:**
|
| 126 |
-
- β
Captures semantic relationships
|
| 127 |
-
- β
Works well for deep learning models
|
| 128 |
-
|
| 129 |
-
**Disadvantages:**
|
| 130 |
-
- β Requires large datasets to train
|
| 131 |
-
- β Computationally expensive
|
| 132 |
-
""")
|
| 133 |
-
|
| 134 |
-
# Sample texts for Word2Vec model
|
| 135 |
-
from gensim.models import Word2Vec
|
| 136 |
-
texts = [
|
| 137 |
-
"Natural Language Processing is fascinating.",
|
| 138 |
-
"Natural Language Processing involves understanding human language.",
|
| 139 |
-
"The field of NLP is growing rapidly."
|
| 140 |
-
]
|
| 141 |
-
model = Word2Vec(sentences=[text.split() for text in texts], vector_size=100, window=5, min_count=1, workers=4)
|
| 142 |
-
word_vectors = model.wv
|
| 143 |
-
word = 'natural'
|
| 144 |
-
if word in word_vectors:
|
| 145 |
-
st.markdown(f'Word2Vec Representation of "{word}":')
|
| 146 |
-
st.write(word_vectors[word])
|
| 147 |
-
else:
|
| 148 |
-
st.markdown(f'Word "{word}" not found in the vocabulary.')
|
| 149 |
-
|
| 150 |
-
# Footer
|
| 151 |
-
st.markdown('<hr>', unsafe_allow_html=True)
|
| 152 |
-
st.markdown('<p class="text" style="text-align:center;">Developed with β€οΈ using Streamlit for NLP enthusiasts.</p>', unsafe_allow_html=True)
|
|
|
|
| 3 |
# Apply custom styles using Streamlit's markdown
|
| 4 |
st.markdown("""
|
| 5 |
<style>
|
| 6 |
+
/* Link to Google Fonts */
|
| 7 |
+
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap');
|
| 8 |
+
|
| 9 |
+
/* Custom styles */
|
| 10 |
+
.main-title {
|
| 11 |
+
color: #FF5733;
|
| 12 |
+
font-size: 40px;
|
| 13 |
+
font-weight: bold;
|
| 14 |
+
text-align: center;
|
| 15 |
+
font-family: 'Roboto', sans-serif; /* Custom font */
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
.section-title {
|
| 19 |
+
color: #2E86C1;
|
| 20 |
+
font-size: 30px;
|
| 21 |
+
font-weight: bold;
|
| 22 |
+
margin-top: 20px;
|
| 23 |
+
font-family: 'Roboto', sans-serif; /* Custom font */
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
.sub-title {
|
| 27 |
+
color: #27AE60;
|
| 28 |
+
font-size: 24px;
|
| 29 |
+
font-weight: bold;
|
| 30 |
+
margin-top: 10px;
|
| 31 |
+
font-family: 'Roboto', sans-serif; /* Custom font */
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
.text {
|
| 35 |
+
font-size: 18px;
|
| 36 |
+
font-family: 'Roboto', sans-serif; /* Custom font */
|
| 37 |
+
}
|
| 38 |
</style>
|
| 39 |
""", unsafe_allow_html=True)
|
| 40 |
|
|
|
|
| 117 |
|
| 118 |
**Disadvantages:**
|
| 119 |
- β Still ignores word order
|
| 120 |
+
- β Does not capture deep
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|