Skip to content

Instantly share code, notes, and snippets.

Bob Lannon boblannon

View GitHub Profile
@boblannon
boblannon / sfm_compare_all.py
Created May 8, 2013
script to demonstrate basic python-superfastmatch pairwise comparison of all documents in a collection
View sfm_compare_all.py
from superfastmatch import client
import uuid
sfm_client = client.Client(url='http://127.0.0.1:9000/')
class Document():
def __init__(self,title_string,content_string):
self.doc_id = uuid.uuid4()
@boblannon
boblannon / residual_IDF.py
Last active Dec 17, 2015
quick and dirty method of using residual IDF to find keywords in a corpus. implementation of chruch and gale 1991
View residual_IDF.py
from collections import defaultdict
from math import log
from math import exp
import pandas as pd
# this is based on data in the form released here: http://corpora.uni-leipzig.de/
# inv_w.txt is a table of (word_id, sentence_id, offset), which lets us create an inverted
# index with offset information
View jenks2.py
import json
from pprint import pprint as pp
def jenks_matrices_init(data, n_classes):
#fill the matrices with data+1 arrays of n_classes 0s
lower_class_limits = []
variance_combinations = []
for i in xrange(0, len(data)+1):
temp1 = []
temp2 = []
@boblannon
boblannon / sfcom_55289_pres-iframe.html
Created Oct 22, 2013
HTML code to embed the 'Contribution Share by Major Political Party' map from "Political influence by county: A new way to look at campaign finance data" http://sunlightfoundation.com/blog/?p=55289
View sfcom_55289_pres-iframe.html
<iframe src="http://assets.sunlightfoundation.com.s3.amazonaws.com/blog/azavea_maps/pres.html" height="703" width="650"></iframe>
@boblannon
boblannon / sfcom_55289_indep-iframe.html
Created Oct 22, 2013
HTML code to embed the 'Third-party presidential giving' map from "Political influence by county: A new way to look at campaign finance data" http://sunlightfoundation.com/blog/?p=55289
View sfcom_55289_indep-iframe.html
<iframe src="http://assets.sunlightfoundation.com.s3.amazonaws.com/blog/azavea_maps/indep.html" height="653" width="650"></iframe>
@boblannon
boblannon / sfcom_55289_pop-iframe.html
Created Oct 22, 2013
HTML code to embed the 'Contributions Per Capita in Each County' map from "Political influence by county: A new way to look at campaign finance data" http://sunlightfoundation.com/blog/?p=55289
View sfcom_55289_pop-iframe.html
<iframe src="http://assets.sunlightfoundation.com.s3.amazonaws.com/blog/azavea_maps/pop.html" height="703" width="650"></iframe>
@boblannon
boblannon / sfcom_55289_total-iframe.html
Created Oct 22, 2013
HTML code to embed the 'Total Contributions From Individuals Over Time' map from "Political influence by county: A new way to look at campaign finance data" http://sunlightfoundation.com/blog/?p=55289
View sfcom_55289_total-iframe.html
<div style="overflow: hidden;"><iframe src="http://assets.sunlightfoundation.com.s3.amazonaws.com/blog/azavea_maps/total.html" height="703" width="650"></iframe></div>
@boblannon
boblannon / keybase.md
Last active Nov 18, 2015
My keybase.io proof
View keybase.md

Keybase proof

I hereby claim:

  • I am boblannon on github.
  • I am boblannon (https://keybase.io/boblannon) on keybase.
  • I have a public key whose fingerprint is DA32 3774 0A70 5FE1 234B E4F3 6543 90FE 7D1B 247B

To claim this, I am signing this object:

View pseudo.py
all_records_that_are_new_or_changed_since_your_last_import = get_all_records_that_are_new_or_changed_since_your_last_import()
for record in all_records_that_are_new_or_changed_since_your_last_import:
found = find_the_record_in_your_old_data(record)
if not found:
add_the_record(record)
if found:
change_whatever_bits_of_the_record_are_different(record)
all_your_existing_data = get_all_your_existing_data()
View pool_loop
for chunk in record_chunks:
pool.apply_async(scoring_function, (chunk,), callback=score_queue.put)
pool.close()
pool.join()
You can’t perform that action at this time.