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
from django.core.exceptions import ObjectDoesNotExist | |
from rest_framework import status | |
from rest_framework.mixins import CreateModelMixin | |
from rest_framework.response import Response | |
class UpdateOrCreateModelMixin(CreateModelMixin): | |
""" | |
Update or create a model instance. | |
""" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 |
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
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) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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): |