Skip to content

Instantly share code, notes, and snippets.

"""Make initial clusters of categories to bootstrap top-level categories."""
from collections import defaultdict
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.cluster import KMeans, MiniBatchKMeans
from j_util import get_rows
a = 'a'
b = 'b'
c = 'c'
d = 'd'
def test_empty():
check([], 0)
def test_all_one():
check([a, a], 1)
sentence = 'Reggie Miller grew up in Riverside before going to UCLA.'
phrase = 'Riverside'
start_index = sentence.find(phrase)
end_index = start_index + len(phrase)
sentence[start_index-10:end_index+10]
# 'rew up in Riverside before go'
import spacy
nlp = spacy.load('en_vectors_web_lg')
text1 = 'The medical field is moving forward rapidly.'
text2 = 'Medicine is vital to the industry.'
text3 = 'Reggie Miller is a basketball player.'
doc1 = nlp(text1)
doc2 = nlp(text2)
import spacy
from spacy.pipeline import EntityRuler
nlp = spacy.load("en_core_web_sm")
ruler = EntityRuler(nlp, validate=True)
ruler.add_patterns[
{
"label": "PHRASE",
"pattern": [
"""Make initial clusters of categories to bootstrap top-level categories."""
from collections import defaultdict
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.cluster import KMeans, MiniBatchKMeans
from j_util import get_rows
from collections import defaultdict
import random
restaurants = [
'za', 'jake', 'spoon', 'hacienda', 'bridgetender', 'river grill', 'rosie', 'sunnyside'
]
people = ['megan', 'jan', 'todd', 'colin', 'michelle']
random.shuffle(people)
IT'S GO TIME
YO YO MA isLessThan20
IT'S IN THE VAULT @IT'S NOT A LIE IF YOU BELIEVE IT
YO YO MA n
IT'S IN THE VAULT 0
YO YO MA multiple
IT'S IN THE VAULT @IT'S NOT A LIE IF YOU BELIEVE IT
CRY CRY AGAIN isLessThan20
IT'S GO TIME
GIDDYUP "Hello, Newman"
YADA YADA YADA
@colinpollock
colinpollock / gist:5871423
Created June 26, 2013 20:38
JestClient search authentication
public static ClientConfig getClientConfig(String connectionUrl) {
ClientConfig clientConfig = new ClientConfig();
LinkedHashSet<String> servers = new LinkedHashSet<String>();
servers.add(connectionUrl);
clientConfig.getServerProperties().put(ClientConstants.SERVER_LIST, servers);
return clientConfig;
}
public static JestClient getClient(String connectionUrl) {
JestClientFactory factory = new JestClientFactory();