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 json | |
import urllib | |
import urllib2 | |
from gensim import corpora, models, similarities | |
import logging | |
import sys | |
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas | |
from matplotlib.figure import Figure |
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
Topic 0: | |
ICFP Programming Contest 2011 (Lambda: The Gathering) http://bit.ly/mfpZk6 #fp #fsharp #ocaml #haskell #scala #lisp #racket #scheme | |
[(0, 0.95871468032041129), (1, 0.079066183724039785)] | |
RT @rickasaurus: ICFP Programming Contest 2011 (Lambda: The Gathering) http://bit.ly/mfpZk6 #fp #fsharp #ocaml #haskell #scala #lisp #racket #scheme | |
[(0, 0.99229220887802994), (1, 0.062785061633268899)] | |
RT @rickasaurus: ICFP Programming Contest 2011 (Lambda: The Gathering) http://bit.ly/mfpZk6 #fp #fsharp #ocaml #haskell #scala #lisp #racket #scheme | |
[(0, 0.99229220887802994), (1, 0.062785061633268899)] |
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
Topic 0: | |
ICFP Programming Contest 2011 (Lambda: The Gathering) http://bit.ly/mfpZk6 #fp #fsharp #ocaml #haskell #scala #lisp #racket #scheme | |
[(0, 0.96213088834451832), (1, -0.053502204689306387), (2, -0.07951428719352148)] | |
RT @rickasaurus: ICFP Programming Contest 2011 (Lambda: The Gathering) http://bit.ly/mfpZk6 #fp #fsharp #ocaml #haskell #scala #lisp #racket #scheme | |
[(0, 0.99540683458237178), (1, -0.034752233550864223), (2, -0.065158846734593753)] | |
RT @rickasaurus: ICFP Programming Contest 2011 (Lambda: The Gathering) http://bit.ly/mfpZk6 #fp #fsharp #ocaml #haskell #scala #lisp #racket #scheme | |
[(0, 0.99540683458237178), (1, -0.034752233550864223), (2, -0.065158846734593753)] |
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 json | |
import urllib | |
import urllib2 | |
from gensim import corpora, models, similarities | |
import logging | |
import sys | |
# First 20 Twitter search results for "python" | |
tweets = [u'Long Integer Objects \u2014 Python v2.7.2 documentation http://bit.ly/jEzUVi', |
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 requests | |
import codecs | |
url = 'http://www.instapaper.com/m' | |
params = {'u': 'http://techcrunch.com/2012/04/30/bn-8-k-microsoft-paying-180m-advance-on-nook-for-windows-8-125m-for-content-tech-acquisition/'} | |
r = requests.get(url, params=params) | |
# r.text holds the response from the server. It appears to be unicode in this case. | |
f = codecs.open("foo.html", mode="w", encoding="UTF-8") | |
f.write(r.text) |
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
print 'hello world' |
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
sentences = [s for rev in reviews for s in rev.split(".")] |
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
// For each line of the input file, remove nonalphanumeric characters, | |
// lowercase all letters, remove stopwords, and write the result to the output | |
// file. I used the answer here as a template for reading/writing files: | |
// http://stackoverflow.com/questions/1821811/how-to-read-write-from-to-file/9739903#9739903 | |
package main | |
import ( | |
"bufio" | |
"fmt" |
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 itertools import permutations | |
perms = permutations(range(6)) | |
def check(p): | |
i1 = p.index(0) < p.index(3) | |
i2 = p.index(1) < p.index(4) | |
i3 = p.index(2) < p.index(1) | |
i4 = p.index(2) < p.index(5) | |
i5 = p.index(3) < p.index(4) |
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 math | |
def sqrt(x, high, low, e): | |
mid = (high + low) / 2.0 | |
square = mid * mid | |
if (square >= x and square - x <= e) or (square < x and x - square <= e): | |
return mid | |
elif square > x: | |
return sqrt(x, high, mid, e) | |
else: |
OlderNewer