desdemona

better_lang_reducer

Jun 8th, 2016
475
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.0
  8. total_lang['pl'] = 0.0
  9. total_lang['hu'] = 0.0
  10. total_lang['de'] = 0.0
  11. total_lang['sv'] = 0.0
  12. total_lang['nl'] = 0.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.     word, en, pl, hu, de, sv, nl = line.split('\t')
  21.  
  22. #    try:
  23.  
  24.     total_lang['en'] += float(en)
  25.     total_lang['pl'] += float(pl)
  26.     total_lang['hu'] += float(hu)
  27.     total_lang['de'] += float(de)
  28.     total_lang['sv'] += float(sv)
  29.     total_lang['nl'] += float(nl)
  30.  
  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