yuanjunchai
commited on
Commit
·
170c474
1
Parent(s):
2d93a92
add application files
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@
|
|
| 2 |
## Mini Project 1 - Part 1: Getting Familiar with Word Embeddings.
|
| 3 |
# This assignment introduces students to text similarity measures using cosine similarity and sentence embeddings.
|
| 4 |
# Students will implement and compare different methods for computing and analyzing text similarity using GloVe and Sentence Transformers.
|
|
|
|
| 5 |
|
| 6 |
#Learning Objectives
|
| 7 |
#By the end of this assignment, students will:
|
|
@@ -265,24 +266,6 @@ def averaged_glove_embeddings_gdrive(sentence, word_index_dict, embeddings, mode
|
|
| 265 |
"""
|
| 266 |
embedding = np.zeros(int(model_type.split("d")[0]))
|
| 267 |
|
| 268 |
-
# # Split sentence into words
|
| 269 |
-
# words = sentence.split()
|
| 270 |
-
# valid_words = 0
|
| 271 |
-
|
| 272 |
-
# for word in words:
|
| 273 |
-
# # Check if the word is in the word_index_dict
|
| 274 |
-
# if word in word_index_dict:
|
| 275 |
-
# word_idx = word_index_dict[word]
|
| 276 |
-
# embedding += embeddings[word_idx]
|
| 277 |
-
# valid_words += 1
|
| 278 |
-
|
| 279 |
-
# if valid_words > 0:
|
| 280 |
-
# raise ValueError("No valid words in sentence")
|
| 281 |
-
|
| 282 |
-
# embedding /= valid_words
|
| 283 |
-
|
| 284 |
-
# return embedding
|
| 285 |
-
|
| 286 |
words = sentence.split()
|
| 287 |
|
| 288 |
valid_word_count = 0
|
|
@@ -463,5 +446,5 @@ if __name__ == "__main__":
|
|
| 463 |
|
| 464 |
st.write("")
|
| 465 |
st.write(
|
| 466 |
-
"
|
| 467 |
)
|
|
|
|
| 2 |
## Mini Project 1 - Part 1: Getting Familiar with Word Embeddings.
|
| 3 |
# This assignment introduces students to text similarity measures using cosine similarity and sentence embeddings.
|
| 4 |
# Students will implement and compare different methods for computing and analyzing text similarity using GloVe and Sentence Transformers.
|
| 5 |
+
# Contributions: Xinghao Li fill the python code, and Yuanjun Chai modify the code and deploy the Streamlit app on the huggingface.
|
| 6 |
|
| 7 |
#Learning Objectives
|
| 8 |
#By the end of this assignment, students will:
|
|
|
|
| 266 |
"""
|
| 267 |
embedding = np.zeros(int(model_type.split("d")[0]))
|
| 268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
words = sentence.split()
|
| 270 |
|
| 271 |
valid_word_count = 0
|
|
|
|
| 446 |
|
| 447 |
st.write("")
|
| 448 |
st.write(
|
| 449 |
+
"Code Written by [Xinghao Li](https://www.linkedin.com/in/lixinghao/), modified and developed by [Yuanjun Chai](https://www.linkedin.com/in/yjchai/)"
|
| 450 |
)
|