This file contains hidden or 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
vocab_file ="/path/to/vocab_file" | |
vectors_file ="/path/to/vectors_file" | |
embed = Embedding(vocab_file,vectors_file) | |
cuisine_refs = ["mexican","chinese","french","british","american"] | |
threshold = 0.2 | |
text = "I want to find an indian restaurant" |
This file contains hidden or 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 sys, os | |
from mitie import * | |
trainer = text_categorizer_trainer("/path/to/total_word_feature_extractor.dat") | |
data = {} # same as before - omitted for brevity | |
for label in training_examples.keys(): | |
for text in training_examples[label]["examples"]: | |
tokens = tokenize(text) |
This file contains hidden or 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 sys, os | |
from mitie import * | |
sample = ner_training_instance(["I", "am", "looking", "for", "some", "cheap", "Mexican", "food", "."]) | |
sample.add_entity(xrange(5,6), "pricerange") | |
sample.add_entity(xrange(6,7), "cuisine") | |
# And we add another training example | |
sample2 = ner_training_instance(["show", "me", "indian", "restaurants", "in", "the", "centre", "."]) | |
sample2.add_entity(xrange(2,3), "cuisine") |
This file contains hidden or 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
\emph{hello} |
This file contains hidden or 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 numpy as np | |
from sklearn.svm import SVC | |
from sklearn.decomposition import PCA | |
from sklearn.cross_validation import train_test_split | |
from sklearn.grid_search import GridSearchCV | |
from sklearn.metrics import classification_report | |
import matplotlib.pyplot as plt | |
import pickle |
This file contains hidden or 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 numpy as np | |
def sum_vecs(embed,text): | |
tokens = text.split(' ') | |
vec = np.zeros(embed.W.shape[1]) | |
for idx, term in enumerate(tokens): | |
if term in embed.vocab: | |
vec = vec + embed.W[embed.vocab[term], :] |
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 hidden or 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 rinocloud as rino | |
import shutil, os | |
import subprocess | |
import hashlib | |
""" | |
persist = Persistor(config.rino_token,config.rino_dir) | |
def save_model_new(persist,model_file,score): | |
temp_file="tmp_{0:06d}.txt".format(random.choice(range(10000))) |
This file contains hidden or 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
"""Implements the long-short term memory character model. | |
This version vectorizes over multiple examples, but each string | |
has a fixed length.""" | |
from __future__ import absolute_import | |
from __future__ import print_function | |
from builtins import range | |
from os.path import dirname, join | |
import numpy as np | |
import numpy.random as npr |
This file contains hidden or 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 __future__ import unicode_literals | |
from __future__ import print_function | |
from __future__ import division | |
from __future__ import absolute_import | |
from builtins import str as text | |
import argparse | |
import io | |
import json |