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
# CoffeeScript version of Google Spreadsheet Driver for Tableau Data Web Connector | |
init = -> | |
if !tableau | |
alert 'init- tableau NOT defined!' | |
return | |
tableau.scriptVersion = '1.0' | |
tableau.log 'init' | |
tableau.initCallback() |
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.models import KeyedVectors | |
# Load gensim word2vec | |
w2v_path = '<Gensim File Path>' | |
w2v = KeyedVectors.load_word2vec_format(w2v_path) | |
import io | |
# Vector file, `\t` seperated the vectors and `\n` seperate the words | |
""" |
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 sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer | |
from sklearn.decomposition import NMF, LatentDirichletAllocation | |
import numpy as np | |
def display_topics(H, W, feature_names, documents, no_top_words, no_top_documents): | |
for topic_idx, topic in enumerate(H): | |
print "Topic %d:" % (topic_idx) | |
print " ".join([feature_names[i] | |
for i in topic.argsort()[:-no_top_words - 1:-1]]) | |
top_doc_indices = np.argsort( W[:,topic_idx] )[::-1][0:no_top_documents] |
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 random | |
import sys | |
def build_chain(text, chain = {}): | |
words = text.split(' ') | |
index = 1 | |
for word in words[index:]: | |
key = words[index - 1] | |
if key in chain: | |
chain[key].append(word) |
NewerOlder