Skip to content

Instantly share code, notes, and snippets.

View interrogator's full-sized avatar

Daniel interrogator

  • UZH
  • Zurich, Switzerland
View GitHub Profile
@interrogator
interrogator / bus.py
Last active May 16, 2016 16:55
Tells you when the next bus is coming
#!/usr/bin/python
def nextbus(where = 'guess', nbus = 5, walking_time = 3):
"""
tells you when the next bus is from home or to uni
where: 'h'/'u'/'guess': home, uni, or try to guess based on wifi connection name
walking_time: don't show buses less than n mins from now
nbus: show next n buses
#!/usr/bin/python
def nextbus(where = 'u', walking_time = 3, nbus = 5):
"""tells you when the next bus is from home or to uni
where: 'h'/'u'
walking_time: don't show buses less than n mins from now
nbus: show next n buses
"""
walking_time = int(walking_time)
LET us go then, you and I,
When the evening is spread out against the sky
Like a patient etherized upon a table;
Let us go, through certain half-deserted streets,
The muttering retreats 5
Of restless nights in one-night cheap hotels
And sawdust restaurants with oyster-shells:
Streets that follow like a tedious argument
Of insidious intent
To lead you to an overwhelming question…. 10
import pickle
import os
bnc = pickle.load(open('bnc.p', 'rb'))
lst = ['clinic', 'hospital', 'patient']
for w in lst:
print '%s: %d occurrences' % ( w, bnc[w])
% gobble allows you to indent in your tex file
% rerun code only if it changes
\usepackage[gobble=auto,rerun=modified]{pythontex}
% a figure showing code and the image it produces
\begin{figure}[htb!]
% make a text box
\begin{mdframed}[backgroundcolor=gray!4] \footnotesize \singlespacing
from setuptools import setup, find_packages
from setuptools.command.install import install
class install_with_nltk_extras(install):
"""Customized setuptools install command - prints a friendly greeting."""
def run(self):
install.run(self)
import nltk
nltk.download('punkt')
nltk.download('wordnet')
@interrogator
interrogator / keywording.py
Last active August 29, 2015 14:23
keywording for eugene to look at
# keyword calculation for a particular word
# our aim is to use log likelihood to calculate the 'keyness' of a word. common practice.
# a normal application would be to loop through wordlists and gives every word a keyness score.
# here, we'll just get 'apple', as an example
# reference_corpus = a dictionary of words and their frequencies in a large dataset
# target_corpus = a dictionary of words and their frequencies in a smaller dataset
# our example word
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>txt</string>
</array>
<key>name</key>
<string>Plain Text</string>
Weeding-Out Urged In Foreign Service: U.S. URGED TO SIFT FOREIGN ...
By E.W. KENWORTHY Special to The New York Times
New York Times (1923-Current file); Dec 29, 1963;
ProQuest Historical Newspapers: The New York Times (1851-2010)
pg.1
Weeding-Out Urged
2005
-5 -4 -3 -2 -1 0 1 2 3 4 5 Total
NN 52 37 43 32 29 88 47 57 40 36 34 495
JJ 23 27 25 11 36 12 30 20 24 30 24 262
NNS 20 23 19 18 15 50 19 26 25 20 26 261
NNP 25 30 35 27 9 2 16 22 17 31 36 250
risk 6 1 1 0 0 177 0 0 1 1 7 194