Skip to content

Instantly share code, notes, and snippets.

View path.py
infile_fullpath = os.path.abspath(args.path_infile)
infile_dir = os.path.dirname(infile_fullpath)
infile_filename = os.path.basename(infile_fullpath)
infile_filename_without_extension, infile_filename_extension = os.path.splitext(infile_filename)
View loadGloVe.py
def loadGloveModel(gloveFile):
# via https://stackoverflow.com/a/38230349
# output: dict (word -> embedding)
print("Loading Glove Model", file=sys.stderr)
model = {}
for i, line in enumerate(gloveFile, start=1):
if i % 100000 == 0:
print("load {} data".format(i), file=sys.stderr)