Beispiel #1
0
def predict_model(model_path, test_txt_path, prediction_dir):

    files = glob.glob(test_txt_path)
    tools.mkpath(prediction_dir)

    # Predict
    predict(files, model_path, prediction_dir, format="i2b2")
Beispiel #2
0
def main():

    txt = []
    line = input('write text:-\n')
    while line:
        txt.append(line)
        line = input()

    filepath = "F:/Programming Documnets/AI/Telehealth/CliNER-master/data/test_predictions/ex_doc.txt"
    file = open(filepath, 'w')
    for i in txt:
        file.write(i + "\n")
    file.close()

    #filepath = "F:/Programming Documnets/AI/Telehealth/CliNER-master/data/examples/ex_doc.txt"

    files = glob.glob(filepath)

    outputpath = "F:/Programming Documnets/AI/Telehealth/CliNER-master/data/test_predictions/"
    tools.mkpath(outputpath)

    filemodel = "F:/Programming Documnets/AI/Telehealth/CliNER-master/models/foo.model"
    model = os.fspath(filemodel)

    # Predict
    predict(files, model, outputpath, format='i2b2')
Beispiel #3
0
def main():

    parser = argparse.ArgumentParser(prog='cliner predict')
    parser.add_argument("--txt",
        dest = "txt",
        help = ".txt files of discharge summaries"
    )
    parser.add_argument("--out",
        dest = "output",
        help = "The directory to write the output",
    )
    parser.add_argument("--model",
        dest = "model",
        help = "The model to use for prediction",
    )
    parser.add_argument("--format",
        dest = "format",
        help = "Data format ( con )"
    )
    args = parser.parse_args()

    # Error check: Ensure that file paths are specified
    if not args.txt:
        print >>sys.stderr, '\n\tError: Must provide text files\n'
        parser.print_help(sys.stderr)
        print >>sys.stderr,  ''
        exit(1)
    if not args.output:
        print >>sys.stderr, '\n\tError: Must provide output directory\n'
        parser.print_help(sys.stderr)
        print >>sys.stderr,  ''
        exit(1)
    if not args.model:
        print >>sys.stderr, '\n\tError: Must provide path to model\n'
        parser.print_help(sys.stderr)
        print >>sys.stderr,  ''
        exit(1)
    if not os.path.exists(args.model):
        print >>sys.stderr, '\n\tError: ClinerModel does not exist: %s\n' % args.model
        parser.print_help(sys.stderr)
        print >>sys.stderr,  ''
        exit(1)


    # Parse arguments
    files = glob.glob(args.txt)
    tools.mkpath(args.output)

    if args.format:
        format = args.format
    else:
        print '\n\tERROR: must provide "format" argument\n'
        exit()


    # Predict
    predict(files, args.model, args.output, format=format)
Beispiel #4
0
def main():

    parser = argparse.ArgumentParser()
    parser.add_argument("--txt", dest="txt")
    parser.add_argument("--out", dest="out")
    parser.add_argument("--model", dest="model")
    parser.add_argument("--format", dest="format")
    args = parser.parse_args()

    if not args.txt or not args.out or not args.model or not os.path.exists(
            args.model):
        parser.print_help(sys.stderr)
        sys.stderr.write('\n\tOne or more files/model not provided\n\n')
        sys.stderr.write('\n')
        exit(1)

    file = glob.glob(args.txt)
    tools.mkpath(args.out)

    tag(file, args.model, args.out)