def main(*args, **kwargs):
    """POS Experiment main entry point."""

    (options, args) = parser.parse_args()
    verbosity = NLTK_Reader.WARN
    if options.verbose:
        verbosity = NLTK_Reader.DEBUG

    reader = NLTK_Reader(input='./resources/text',
                         cache_dir='./cache/text',
                         verbosity=verbosity)

    simple_tags = not options.full_tagging

    if options.text_info:
        reader.text_report()
    if options.list_texts:
        print 'Available texts:'
        for t in reader.available_texts():
            print '\t%s' % t

    if options.input_text:
        target_text = options.input_text
    else:
        target_text = None

    if target_text is not None:
        if options.pos_report:
            print 'Parts of Speech found in %s:' % target_text
            for pos in reader.get_parts_of_speech(target_text,
                                                  simplify_tags=simple_tags):
                tag_description = reader.describe_tag(pos)
                print '\t%6s  %s (%s)' % (pos, tag_description[0],
                                          tag_description[1])
        else:
            output_dir = options.output_dir

            model = ModelFactory.create(run_pos_model_params.MODEL_PARAMS)
            model.enableInference({'predictedField': 'pos'})

            if output_dir:
                if not os.path.exists(output_dir):
                    os.mkdir(output_dir)
                output_file_path = os.path.join(output_dir,
                                                'pos_out_' + target_text)
                # Clear the output file with a header.
                with open(output_file_path, 'w') as output_file:
                    output_file.write('%10s%10s%20s\n' %
                                      ('input', 'pos', 'predicted_pos'))
                # Append each result to output file.
                with open(output_file_path, 'a') as output_file:
                    run_pos_experiment(model, reader, target_text, simple_tags,
                                       output_file)
            else:
                run_pos_experiment(model, reader, target_text, simple_tags)
def main(*args, **kwargs):
    """POS Experiment main entry point."""

    (options, args) = parser.parse_args()
    verbosity = NLTK_Reader.WARN
    if options.verbose:
        verbosity = NLTK_Reader.DEBUG

    reader = NLTK_Reader(input="./resources/text", cache_dir="./cache/text", verbosity=verbosity)

    simple_tags = not options.full_tagging

    if options.text_info:
        reader.text_report()
    if options.list_texts:
        print "Available texts:"
        for t in reader.available_texts():
            print "\t%s" % t

    if options.input_text:
        target_text = options.input_text
    else:
        target_text = None

    if target_text is not None:
        if options.pos_report:
            print "Parts of Speech found in %s:" % target_text
            for pos in reader.get_parts_of_speech(target_text, simplify_tags=simple_tags):
                tag_description = reader.describe_tag(pos)
                print "\t%6s  %s (%s)" % (pos, tag_description[0], tag_description[1])
        else:
            output_dir = options.output_dir

            model = ModelFactory.create(run_pos_model_params.MODEL_PARAMS)
            model.enableInference({"predictedField": "pos"})

            if output_dir:
                if not os.path.exists(output_dir):
                    os.mkdir(output_dir)
                output_file_path = os.path.join(output_dir, "pos_out_" + target_text)
                # Clear the output file with a header.
                with open(output_file_path, "w") as output_file:
                    output_file.write("%10s%10s%20s\n" % ("input", "pos", "predicted_pos"))
                # Append each result to output file.
                with open(output_file_path, "a") as output_file:
                    run_pos_experiment(model, reader, target_text, simple_tags, output_file)
            else:
                run_pos_experiment(model, reader, target_text, simple_tags)