Example #1
0
def main():
    kinds = getKinds()

    # #################################################
    # options parsing

    options = cli.getOptions(kinds, step=cli.steps.PREPARATION)

    # #################################################
    # main

    if (options.inputfile):
        # split --file argument
        options.infile = os.path.normpath(os.path.abspath(
            options.inputfile[0]))  # IN
        options.outfile = os.path.normpath(
            os.path.abspath(options.inputfile[1]))  # OUT
        applyFile(options.kind, options.infile, options)
    elif (options.inputlist):
        # handle --list argument
        options.inputlist = os.path.normpath(os.path.abspath(
            options.inputlist))
        if (options.allkinds):
            applyAllPreparationKindsToFolders(options.inputlist, options)
        else:
            applyFolders(options.kind, options.inputlist, options)
    else:
        print >> sys.stderr, "This should not happen! No input file or list of projects given!"
        sys.exit(1)
Example #2
0
def main():
    kinds = getKinds()

    # #################################################
    # options parsing

    options = cli.getOptions(kinds, step=cli.steps.PREPARATION)

    # #################################################
    # main

    if (options.inputfile):

        # split --file argument
        options.infile = os.path.normpath(os.path.abspath(
            options.inputfile[0]))  # IN
        options.outfile = os.path.normpath(
            os.path.abspath(options.inputfile[1]))  # OUT

        # check if inputfile exists
        if (not os.path.isfile(options.infile)):
            print "ERROR: input file '{}' cannot be found!".format(
                options.infile)
            sys.exit(1)

        applyFile(options.kind, options.infile, options)

    elif (options.inputlist):
        # handle --list argument
        options.inputlist = os.path.normpath(os.path.abspath(
            options.inputlist))  # LIST

        # check if list file exists
        if (not os.path.isfile(options.inputlist)):
            print "ERROR: input file '{}' cannot be found!".format(
                options.inputlist)
            sys.exit(1)

        if (options.allkinds):
            applyFoldersAll(options.inputlist, options)
        else:
            applyFolders(options.kind, options.inputlist, options)

    else:
        print "This should not happen! No input file or list of projects given!"
        sys.exit(1)
Example #3
0
def main():
    kinds = getKinds()

    # #################################################
    # options parsing

    options = cli.getOptions(kinds, step=cli.steps.PREPARATION)

    # #################################################
    # main

    if (options.inputfile):

        # split --file argument
        options.infile = os.path.normpath(os.path.abspath(options.inputfile[0]))  # IN
        options.outfile = os.path.normpath(os.path.abspath(options.inputfile[1]))  # OUT

        # check if inputfile exists
        if (not os.path.isfile(options.infile)):
            print "ERROR: input file '{}' cannot be found!".format(options.infile)
            sys.exit(1)

        applyFile(options.kind, options.infile, options)

    elif (options.inputlist):
        # handle --list argument
        options.inputlist = os.path.normpath(os.path.abspath(options.inputlist))  # LIST

        # check if list file exists
        if (not os.path.isfile(options.inputlist)):
            print "ERROR: input file '{}' cannot be found!".format(options.inputlist)
            sys.exit(1)

        if (options.allkinds):
            applyFoldersAll(options.inputlist, options)
        else:
            applyFolders(options.kind, options.inputlist, options)

    else:
        print "This should not happen! No input file or list of projects given!"
        sys.exit(1)
Example #4
0
import json
import re
import cli

(options, args) = cli.getOptions()

cmip3 = open(options.source, "r")
cmipData = []
output = {"name": options.name, "data": cmipData}
ensembleRegex = r'ensemble member\s+'
datapointRegex = r'\d+\.\d+'
currentEnsemble = None

for line in cmip3.readlines():
    ensembleMatch = re.search(ensembleRegex, line, flags=0)
    datapointMatch = re.search(datapointRegex, line, flags=0)
    # get lines starting with ensemble members
    if (ensembleMatch):
        currentEnsemble = int(line[ensembleMatch.end():])

    if (datapointMatch):
        datapoints = line.split()
        current = {
            "ensembleNumber": currentEnsemble,
            "year": int(float(datapoints[0])),
            "mean": float(datapoints[1])
        }
        cmipData.append(current)

formattedData = []
for item in cmipData:
Example #5
0
def writeStats(file, answers):
    out = file
    for a in answers:
        out.write("ACTUAL TEXT:\n" + a[0] + " " + str(len(a[0])) + "\n")
        out.write("BEST GUESS:\n" + a[1] + " " + str(len(a[1])) + "\n")
        out.write("FEATURE EXTRACTOR: " + a[2] + "\n")
        out.write("LINGUIST: " + a[3] + "\n")
        out.write("LETTERS IDENTIFIED: " + str(a[4]) + "\n")
        out.write("PERCENT LETTERS IDENTIFIED: " + str(a[5]) + "\n")
        out.write("EDIT DISTANCE: " + str(a[6]) + "\n")
        out.write("\n")


if __name__ == "__main__":
    options, parser = cli.getOptions()
    dirName = options.target
    try:
        files = os.listdir(dirName)
    except:
        sys.stderr.write("tester.py takes in a directory name, not an image name\n")
        sys.exit(0)
    images = []
    for f in files:
        if f[-4:] == ".png" or f[-4:] == ".jpg":
            images.append(f)
    for i in range(len(images)):
        print images[i]
        print images
        options.target = dirName + "/" + images[i]
        text = getText(options.target)