Beispiel #1
0
def termCount( index, term ):
    '''
    Returns the number of time representive at index used 'term' in debates & hansard
    '''
    global reps
    store_key = "termcount_%s" % term # store the result with each rep using this key
    if not reps[index].has_key( store_key ):
        reps[index][store_key] = oa.termCount( term, reps[index]['person_id'], debates=True, hansard=True, comments=False )
    return reps[index][store_key]
Beispiel #2
0
#!/usr/bin/env python
import urllib2
import xml.dom.minidom as xml
import oa

# get representatives
result = oa.request( "getRepresentatives" )
dom = xml.parseString(result)
representatives = dom.getElementsByTagName("match")
print "Num Representatives: %d" % len(representatives)

# exercise term counting.
for term in ["promiscuity","affair","web","broadband"]:
    print 'Term %s: %d' % (term,oa.termCount(term))
    print "Term %s in %s: %d" % (term, "hansards", oa.termCount(term, debates=False, comments=False))