autocorrect - annna - Annna the nice friendly bot.
HTML git clone git://bitreich.org/annna/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/annna/
DIR Log
DIR Files
DIR Refs
DIR Tags
DIR README
---
autocorrect (631B)
---
1 #!/usr/bin/env python
2 # coding=utf-8
3
4 import os
5 import sys
6 import getopt
7 import io
8 from autocorrect import Speller
9
10 def usage(app):
11 app = os.path.basename(app)
12 print("usage: %s [-h] str..." % (app), file=sys.stderr)
13 sys.exit(1)
14
15 def main(args):
16 try:
17 opts, largs = getopt.getopt(args[1:], "h")
18 except getopt.GetoptError as err:
19 print(str(err))
20 usage(args[0])
21
22 for o, a in opts:
23 if o == "-h":
24 usage(args[0])
25 else:
26 assert False, "unhandled option"
27
28 if len(largs) < 1:
29 usage(args[0])
30
31 spell = Speller()
32 print("%s" % (spell(" ".join(largs))))
33
34 return 0
35
36 if __name__ == "__main__":
37 sys.exit(main(sys.argv))
38