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
def chunk(msg, n): | |
words = msg.split(" ") | |
totalPages = 1 | |
prevTotalPages = 0 | |
while totalPages != prevTotalPages: | |
chunks = [] | |
chunk = [] | |
for word in words: | |
page = "(%d/%d)" % (len(chunks) + 1, totalPages) | |
if len(" ".join(chunk + [page])) > n: |
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
""" | |
(C) Mathieu Blondel - 2010 | |
Implementation of the collapsed Gibbs sampler for | |
Latent Dirichlet Allocation, as described in | |
Finding scientifc topics (Griffiths and Steyvers) | |
""" | |
import numpy as np |
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
require "matrix" | |
def cross( v, w ) | |
x = v[1]*w[2] - v[2]*w[1] | |
y = v[2]*w[0] - v[0]*w[2] | |
z = v[0]*w[1] - v[1]*w[0] | |
Vector[x,y,z] | |
end | |
def multi_sumV( v, w ) |
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
# Script to test stemming for ElasticSearch. Working now!! | |
# Reference: http://stackoverflow.com/questions/4981001/why-elasticsearch-is-not-finding-my-term | |
require 'rubygems' | |
require 'net/http' | |
require 'yaml' | |
require 'json' | |
# kill the index | |
delete = Net::HTTP::Delete.new("/willindex") |