Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: rcompton on Mar 28th, 2013  |  syntax: None  |  size: 0.45 KB  |  views: 34  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/python2.6
  2.  
  3. import argparse
  4. import random
  5. import langid
  6. import sys,os
  7.  
  8. if len(sys.argv) < 2:
  9.     sys.exit(0)
  10.    
  11. id = sys.argv[1]
  12.    
  13. parser = argparse.ArgumentParser(description='Run langid classifier on command line text')
  14. parser.add_argument('text', type=str, nargs="+")
  15. args = parser.parse_args(sys.argv[2:])
  16.    
  17. args.text = ' '.join(args.text)
  18. (lang,prob) = langid.classify(args.text)
  19. print "%s\t%s" %(id,lang)
  20. sys.exit(0)
clone this paste RAW Paste Data