desdemona

lang_reducer.py

May 30th, 2016
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. from operator import itemgetter
  4. import sys
  5.  
  6. total_lang = {}
  7. total_lang['en'] = 0
  8. total_lang['pl'] = 0
  9. total_lang['hu'] = 0
  10. total_lang['de'] = 0
  11. total_lang['sv'] = 0
  12. total_lang['nl'] = 0
  13.  
  14. #print word + "\t" + en + "\t" + pl + "\t" + hu + "\t" + de + "\t" + sv + "\t" + nl
  15.  
  16.  
  17. for line in sys.stdin:
  18.  
  19.     line = line.strip()
  20.  
  21.     word, en, pl, hu, de, sv, nl = line.split('\t')
  22.  
  23.     try:
  24.  
  25.         total_lang['en'] += int(en)
  26.         total_lang['pl'] += int(pl)
  27.         total_lang['hu'] += int(hu)
  28.         total_lang['de'] += int(de)
  29.         total_lang['sv'] += int(sv)
  30.         total_lang['nl'] += int(nl)
  31.  
  32.     except ValueError:
  33.         pass
  34.  
  35. print "Total points: "+ " en:" + str(total_lang['en']) + " pl:" + str(total_lang['pl']) + " hu:" + str(total_lang['hu']) + " de:" + str(total_lang['de']) + " sv:" + str(total_lang['sv']) + " nl:" + str(total_lang['nl'])
  36. print "Language probably is: " + max(total_lang.iteritems(), key=itemgetter(1))[0]
Add Comment
Please, Sign In to add comment