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
"""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 | |
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
a = 'a' | |
b = 'b' | |
c = 'c' | |
d = 'd' | |
def test_empty(): | |
check([], 0) | |
def test_all_one(): | |
check([a, a], 1) |
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
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' |
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 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) |
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 spacy | |
from spacy.pipeline import EntityRuler | |
nlp = spacy.load("en_core_web_sm") | |
ruler = EntityRuler(nlp, validate=True) | |
ruler.add_patterns[ | |
{ | |
"label": "PHRASE", | |
"pattern": [ |
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
"""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 | |
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 collections import defaultdict | |
import random | |
restaurants = [ | |
'za', 'jake', 'spoon', 'hacienda', 'bridgetender', 'river grill', 'rosie', 'sunnyside' | |
] | |
people = ['megan', 'jan', 'todd', 'colin', 'michelle'] | |
random.shuffle(people) |
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
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 |
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
IT'S GO TIME | |
GIDDYUP "Hello, Newman" | |
YADA YADA YADA |
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
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(); |
NewerOlder