changeset 3:047f65d57d81 draft

Uploaded
author moba
date Tue, 02 May 2017 06:04:50 -0400
parents 57e86cd394e8
children f64cd17140fe
files alvis-annotator.py
diffstat 1 files changed, 69 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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()
+