# HG changeset patch # User moba # Date 1493719490 14400 # Node ID 047f65d57d81464caffdc5809c9ce6bb66c19c91 # Parent 57e86cd394e87ee1e3b8b6e9024a8dc5f24c6de3 Uploaded diff -r 57e86cd394e8 -r 047f65d57d81 alvis-annotator.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/alvis-annotator.py Tue May 02 06:04:50 2017 -0400 @@ -0,0 +1,69 @@ +#!/usr/bin/python2 + +# Filename: grep.py +# Author: Mouhamadou Ba +# Version: 20/07/2016 + +# This function is exceedingly useful, perhaps package for reuse? +def getopts(argv): + opts = {} + while argv: + if argv[0][0] == '-': + opts[argv[0]] = argv[1] + argv = argv[2:] + else: + argv = argv[1:] + return opts + + + +def main(): + args = sys.argv[1:] + + try: + opts = getopts(args) + except IndexError: + print "Usage:" + print "-input text corpus" + print "-dict dictionary file" + print "-output output file" + + + input_p = opts.get("-input") + if input_p == None: + print "No value specified" + return -1 + + dict_p = opts.get("-dict") + if dict_p == None: + print "No value specified" + return -2 + + output_p = opts.get("-output") + if output_p == None: + print "No value specified" + return -3 + + # generate alvisnlp commandOptions + commandOptions ="" + if verbose == "true" : + commandOptions = " -verbose " + + if colors == "true" : + commandOptions = commandOptions + "-noColors " + + commandline = "alvisnlp -param input %s -param dict %s -param output %s plans/alvis-annotator.plan" % ( input_p , dict_p , output_p ) + + # run alvisnlp + print commandline + + # errorcode, stdout = commands.getstatusoutput(commandline) + os.system(commandline) + + # return error code + #return errorcode + + +if __name__ == "__main__": + main() +