#!/usr/bin/env python 
import mincemeat
import sys
import great_bigrams

def mapfn(k, v):
    counts = great_bigrams.do_map(v)
    for val,count in counts.items():
        yield val,count

def reducefn(k, vs):
    result = sum(vs)
    return result

s = mincemeat.Server() 

s.map_input = mincemeat.FileMapInput(sys.argv[1]) 
s.mapfn = mapfn
s.reducefn = reducefn

results = s.run_server(password="changeme") 
mincemeat.dump_results(results)
