def topic_coherence(lists, services=['ca', 'cp', 'cv', 'npmi', 'uci', 'umass']):
 url = u'http://palmetto.aksw.org/palmetto-webapp/service/{}?words={}'
 reqs = [url.format(s, '%20'.join(top[:10])) for s in services for top in lists]
 pool = multiprocessing.Pool()
 coherences = pool.map(get_request, reqs)
 pool.close()
 pool.terminate()
 pool.join()
 del pool
 args = [(j, s, top) for s in services for (j, top) in enumerate(lists)]
 ans = {}
 for ((j, s, t), tc) in zip(args, coherences):
  ans[(j, s)] = tc
 return ans

def topic_coherence ( lists , services = [ 'ca' , 'cp' , 'cv' , 'npmi' , 'uci' , 'umass' ] ) : url = u'http://palmetto.aksw.org/palmetto-webapp/service/{}?words={}' reqs = [ url . format ( s , '%20' . join ( top [ : 10 ] ) ) for s in services for top in lists ] pool = multiprocessing . Pool ( ) coherences = pool . map ( get_request , reqs ) pool . close ( ) pool . terminate ( ) pool . join ( ) del pool args = [ ( j , s , top ) for s in services for ( j , top ) in enumerate ( lists ) ] ans = { } for ( ( j , s , t ) , tc ) in zip ( args , coherences ) : ans [ ( j , s ) ] = tc return ans
requests the topic coherence from aksw palmetto arguments lists : list of lists a list of lists with one list of top words for each topic .