forked from totalgood/nlpia
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hobson Lane
committed
Jul 17, 2021
1 parent
43da358
commit c3b9f12
Showing
10 changed files
with
1,529 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
""" NLPIA chapter 6 glove nessvectors | ||
Dependencies: | ||
* python==3.6.12 | ||
* scann== | ||
References: | ||
* Stanford NLP's GloVe model and training script [https://github.com/stanfordnlp/glove] | ||
* Erik Bern's ANN benchmarks with training and testsets: https://github.com/erikbern/ann-benchmarks | ||
* Spotify's Annoy (with good visualization): [https://github.com/spotify/annoy] | ||
* Google Research's ScaNN: [pip install scann]() | ||
""" | ||
|
||
|
||
import np | ||
|
||
|
||
def load_glove(filepath): | ||
# print("Loading Glove Model") | ||
f = open(filepath, 'r') | ||
wv = {} | ||
for line in f: | ||
splitLines = line.split() | ||
word = splitLines[0] | ||
embedding = np.array([float(value) for value in splitLines[1:]]) | ||
wv[word] = embedding | ||
# print(len(wv), " words loaded!") | ||
return wv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.