Skip to content

Instantly share code, notes, and snippets.

View Notebook like a boss.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View word2vec_tf_idf_load.py
from gensim.corpora.wikicorpus import WikiCorpus
from gensim.models import TfidfModel
wiki = WikiCorpus.load('wiki.corpus')
tfidf = TfidfModel.load("wiki.gensim.tfidfmodel")
# transform sentence in bow
sentence = "hi my name is"
sentence = wiki.dictionary.doc2bow(sentence.lower().split()) # [(662762, 1), (1271346, 1), (1756375, 1), (1770642, 1)]
# tfidf for that sentence
@maxbellec
maxbellec / word2vec_tf_idf_from_wikipeida.py
Last active Sep 17, 2018
Create Word2Vec from wikipedia with gensim
View word2vec_tf_idf_from_wikipeida.py
import multiprocessing
from gensim.corpora.wikicorpus import WikiCorpus
from gensim.models.word2vec import Word2Vec
from gensim.models import TfidfModel
# logging is important to get the state of the functions
import logging
logging.basicConfig(format='%(asctime)s: %(levelname)s: %(message)s')
logging.root.setLevel(level=logging.INFO)
View report.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@maxbellec
maxbellec / get_lat_lon_exif_pil.py
Last active Feb 26, 2019 — forked from erans/get_lat_lon_exif_pil.py
Get Latitude and Longitude from EXIF using PIL
View get_lat_lon_exif_pil.py
import PIL.Image
get_float = lambda x: float(x[0]) / float(x[1])
def convert_to_degrees(value):
d = get_float(value[0])
m = get_float(value[1])
s = get_float(value[2])
return d + (m / 60.0) + (s / 3600.0)
def get_lat_lon(info):