Esempio n. 1
0
def generate_ngrams_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to add n-grams data
    to the data store."""
    parser = subparsers.add_parser('ngrams',
                                   description=constants.NGRAMS_DESCRIPTION,
                                   epilog=constants.NGRAMS_EPILOG,
                                   formatter_class=ParagraphFormatter,
                                   help=constants.NGRAMS_HELP)
    parser.set_defaults(func=generate_ngrams)
    utils.add_common_arguments(parser)
    parser.add_argument('-c',
                        '--catalogue',
                        dest='catalogue',
                        help=constants.NGRAMS_CATALOGUE_HELP,
                        metavar='CATALOGUE')
    utils.add_db_arguments(parser)
    utils.add_corpus_arguments(parser)
    parser.add_argument('min_size',
                        help=constants.NGRAMS_MINIMUM_HELP,
                        metavar='MINIMUM',
                        type=int)
    parser.add_argument('max_size',
                        help=constants.NGRAMS_MAXIMUM_HELP,
                        metavar='MAXIMUM',
                        type=int)
Esempio n. 2
0
def generate_collapse_witness_results_subparser(subparsers):
    parser = subparsers.add_parser(
        "collapse-witnesses",
        description=constants.TACL_HELPER_COLLAPSE_DESCRIPTION,
        help=constants.TACL_HELPER_COLLAPSE_HELP,
    )
    parser.set_defaults(func=collapse_witnesses)
    utils.add_common_arguments(parser)
    utils.add_tokenizer_argument(parser)
    parser.add_argument("results", help=constants.TACL_HELPER_RESULTS_HELP, metavar="RESULTS")
Esempio n. 3
0
def generate_label_count_subparser(subparsers):
    parser = subparsers.add_parser(
        "label-count",
        description=constants.TACL_HELPER_LABEL_COUNT_DESCRIPTION,
        help=constants.TACL_HELPER_LABEL_COUNT_HELP,
    )
    parser.set_defaults(func=label_count)
    utils.add_common_arguments(parser)
    utils.add_tokenizer_argument(parser)
    parser.add_argument("results", help=constants.TACL_HELPER_RESULTS_HELP, metavar="RESULTS")
Esempio n. 4
0
def generate_validate_catalogue_subparser(subparsers):
    parser = subparsers.add_parser(
        "validate-catalogue",
        description=constants.TACL_HELPER_VALIDATE_CATALOGUE_DESCRIPTION,
        help=constants.TACL_HELPER_VALIDATE_CATALOGUE_HELP,
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
    )
    parser.set_defaults(func=validate_catalogue)
    utils.add_common_arguments(parser)
    utils.add_corpus_arguments(parser)
    utils.add_query_arguments(parser)
Esempio n. 5
0
def generate_parser():
    parser = argparse.ArgumentParser(description=constants.JITC_DESCRIPTION)
    utils.add_common_arguments(parser)
    utils.add_db_arguments(parser)
    utils.add_corpus_arguments(parser)
    utils.add_query_arguments(parser)
    parser.add_argument('label', help=constants.JITC_LABEL_HELP,
                        metavar='LABEL')
    parser.add_argument('output', help=constants.REPORT_OUTPUT_HELP,
                        metavar='OUTPUT')
    return parser
Esempio n. 6
0
def generate_statistics_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to generate statistics
    from a set of results."""
    parser = subparsers.add_parser(
        "stats",
        description=constants.STATISTICS_DESCRIPTION,
        formatter_class=ParagraphFormatter,
        help=constants.STATISTICS_HELP,
    )
    parser.set_defaults(func=generate_statistics)
    utils.add_common_arguments(parser)
    utils.add_corpus_arguments(parser)
    parser.add_argument("results", help=constants.STATISTICS_RESULTS_HELP, metavar="RESULTS")
Esempio n. 7
0
def generate_counts_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to make a counts
    query."""
    parser = subparsers.add_parser('counts',
                                   description=constants.COUNTS_DESCRIPTION,
                                   epilog=constants.COUNTS_EPILOG,
                                   formatter_class=ParagraphFormatter,
                                   help=constants.COUNTS_HELP)
    parser.set_defaults(func=ngram_counts)
    utils.add_common_arguments(parser)
    utils.add_db_arguments(parser)
    utils.add_corpus_arguments(parser)
    utils.add_query_arguments(parser)
Esempio n. 8
0
def generate_parser():
    parser = argparse.ArgumentParser(description=constants.JITC_DESCRIPTION)
    utils.add_common_arguments(parser)
    utils.add_db_arguments(parser)
    utils.add_corpus_arguments(parser)
    utils.add_query_arguments(parser)
    parser.add_argument('label',
                        help=constants.JITC_LABEL_HELP,
                        metavar='LABEL')
    parser.add_argument('output',
                        help=constants.REPORT_OUTPUT_HELP,
                        metavar='OUTPUT')
    return parser
Esempio n. 9
0
def generate_supplied_intersect_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to run an intersect query
    using the supplied results sets."""
    parser = subparsers.add_parser(
        'sintersect',
        description=constants.SUPPLIED_INTERSECT_DESCRIPTION,
        epilog=constants.SUPPLIED_INTERSECT_EPILOG,
        formatter_class=ParagraphFormatter,
        help=constants.SUPPLIED_INTERSECT_HELP)
    parser.set_defaults(func=supplied_intersect)
    utils.add_common_arguments(parser)
    utils.add_db_arguments(parser, True)
    utils.add_supplied_query_arguments(parser)
Esempio n. 10
0
def generate_intersect_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to make an
    intersection query."""
    parser = subparsers.add_parser('intersect',
                                   description=constants.INTERSECT_DESCRIPTION,
                                   epilog=constants.INTERSECT_EPILOG,
                                   formatter_class=ParagraphFormatter,
                                   help=constants.INTERSECT_HELP)
    parser.set_defaults(func=ngram_intersection)
    utils.add_common_arguments(parser)
    utils.add_db_arguments(parser)
    utils.add_corpus_arguments(parser)
    utils.add_query_arguments(parser)
Esempio n. 11
0
def generate_strip_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to process prepared files
    for use with the tacl ngrams command."""
    parser = subparsers.add_parser(
        "strip",
        description=constants.STRIP_DESCRIPTION,
        epilog=constants.STRIP_EPILOG,
        formatter_class=ParagraphFormatter,
        help=constants.STRIP_HELP,
    )
    parser.set_defaults(func=strip_files)
    utils.add_common_arguments(parser)
    parser.add_argument("input", help=constants.STRIP_INPUT_HELP, metavar="INPUT")
    parser.add_argument("output", help=constants.STRIP_OUTPUT_HELP, metavar="OUTPUT")
Esempio n. 12
0
def generate_statistics_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to generate statistics
    from a set of results."""
    parser = subparsers.add_parser(
        'stats',
        description=constants.STATISTICS_DESCRIPTION,
        formatter_class=ParagraphFormatter,
        help=constants.STATISTICS_HELP)
    parser.set_defaults(func=generate_statistics)
    utils.add_common_arguments(parser)
    utils.add_corpus_arguments(parser)
    parser.add_argument('results',
                        help=constants.STATISTICS_RESULTS_HELP,
                        metavar='RESULTS')
Esempio n. 13
0
def generate_supplied_intersect_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to run an intersect query
    using the supplied results sets."""
    parser = subparsers.add_parser(
        "sintersect",
        description=constants.SUPPLIED_INTERSECT_DESCRIPTION,
        epilog=constants.SUPPLIED_INTERSECT_EPILOG,
        formatter_class=ParagraphFormatter,
        help=constants.SUPPLIED_INTERSECT_HELP,
    )
    parser.set_defaults(func=supplied_intersect)
    utils.add_common_arguments(parser)
    utils.add_db_arguments(parser, True)
    utils.add_supplied_query_arguments(parser)
Esempio n. 14
0
def generate_supplied_diff_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to run a diff query using
    the supplied results sets."""
    parser = subparsers.add_parser(
        'sdiff',
        description=constants.SUPPLIED_DIFF_DESCRIPTION,
        epilog=constants.SUPPLIED_DIFF_EPILOG,
        formatter_class=ParagraphFormatter,
        help=constants.SUPPLIED_DIFF_HELP)
    parser.set_defaults(func=supplied_diff)
    utils.add_common_arguments(parser)
    utils.add_tokenizer_argument(parser)
    utils.add_db_arguments(parser, True)
    utils.add_supplied_query_arguments(parser)
Esempio n. 15
0
def generate_supplied_diff_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to run a diff query using
    the supplied results sets."""
    parser = subparsers.add_parser(
        "sdiff",
        description=constants.SUPPLIED_DIFF_DESCRIPTION,
        epilog=constants.SUPPLIED_DIFF_EPILOG,
        formatter_class=ParagraphFormatter,
        help=constants.SUPPLIED_DIFF_HELP,
    )
    parser.set_defaults(func=supplied_diff)
    utils.add_common_arguments(parser)
    utils.add_tokenizer_argument(parser)
    utils.add_db_arguments(parser, True)
    utils.add_supplied_query_arguments(parser)
Esempio n. 16
0
def generate_counts_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to make a counts
    query."""
    parser = subparsers.add_parser(
        "counts",
        description=constants.COUNTS_DESCRIPTION,
        epilog=constants.COUNTS_EPILOG,
        formatter_class=ParagraphFormatter,
        help=constants.COUNTS_HELP,
    )
    parser.set_defaults(func=ngram_counts)
    utils.add_common_arguments(parser)
    utils.add_db_arguments(parser)
    utils.add_corpus_arguments(parser)
    utils.add_query_arguments(parser)
Esempio n. 17
0
def generate_intersect_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to make an
    intersection query."""
    parser = subparsers.add_parser(
        "intersect",
        description=constants.INTERSECT_DESCRIPTION,
        epilog=constants.INTERSECT_EPILOG,
        formatter_class=ParagraphFormatter,
        help=constants.INTERSECT_HELP,
    )
    parser.set_defaults(func=ngram_intersection)
    utils.add_common_arguments(parser)
    utils.add_db_arguments(parser)
    utils.add_corpus_arguments(parser)
    utils.add_query_arguments(parser)
Esempio n. 18
0
def generate_work_in_corpus_subparser(subparsers):
    parser = subparsers.add_parser(
        "work-in-corpus",
        description=constants.TACL_HELPER_IN_DESCRIPTION,
        help=constants.TACL_HELPER_IN_HELP,
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
    )
    parser.set_defaults(func=work_in_corpus)
    utils.add_common_arguments(parser)
    utils.add_db_arguments(parser)
    utils.add_corpus_arguments(parser)
    parser.add_argument(
        "works", help=constants.TACL_HELPER_IN_TEXTS_HELP, metavar="FILE_LIST", type=argparse.FileType("r")
    )
    parser.add_argument("output_dir", help=constants.TACL_HELPER_OUTPUT, metavar="OUTPUT_DIR")
Esempio n. 19
0
def generate_search_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to generate search
    results for a set of n-grams."""
    parser = subparsers.add_parser(
        "search",
        description=constants.SEARCH_DESCRIPTION,
        formatter_class=ParagraphFormatter,
        help=constants.SEARCH_HELP,
    )
    parser.set_defaults(func=search_texts)
    utils.add_common_arguments(parser)
    utils.add_db_arguments(parser)
    utils.add_corpus_arguments(parser)
    parser.add_argument("-c", "--catalogue", metavar="CATALOGUE", help=constants.CATALOGUE_CATALOGUE_HELP)
    parser.add_argument("ngrams", help=constants.SEARCH_NGRAMS_HELP, metavar="NGRAMS")
Esempio n. 20
0
def generate_catalogue_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to generate and save
    a catalogue file."""
    parser = subparsers.add_parser(
        "catalogue",
        description=constants.CATALOGUE_DESCRIPTION,
        epilog=constants.CATALOGUE_EPILOG,
        formatter_class=ParagraphFormatter,
        help=constants.CATALOGUE_HELP,
    )
    utils.add_common_arguments(parser)
    parser.set_defaults(func=generate_catalogue)
    parser.add_argument("corpus", help=constants.DB_CORPUS_HELP, metavar="CORPUS")
    utils.add_query_arguments(parser)
    parser.add_argument("-l", "--label", default="", help=constants.CATALOGUE_LABEL_HELP)
Esempio n. 21
0
def generate_search_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to generate search
    results for a set of n-grams."""
    parser = subparsers.add_parser('search',
                                   description=constants.SEARCH_DESCRIPTION,
                                   formatter_class=ParagraphFormatter,
                                   help=constants.SEARCH_HELP)
    parser.set_defaults(func=search_texts)
    utils.add_common_arguments(parser)
    utils.add_db_arguments(parser)
    utils.add_corpus_arguments(parser)
    utils.add_query_arguments(parser)
    parser.add_argument('ngrams',
                        help=constants.SEARCH_NGRAMS_HELP,
                        metavar='NGRAMS')
Esempio n. 22
0
def generate_strip_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to process prepared files
    for use with the tacl ngrams command."""
    parser = subparsers.add_parser('strip',
                                   description=constants.STRIP_DESCRIPTION,
                                   epilog=constants.STRIP_EPILOG,
                                   formatter_class=ParagraphFormatter,
                                   help=constants.STRIP_HELP)
    parser.set_defaults(func=strip_files)
    utils.add_common_arguments(parser)
    parser.add_argument('input',
                        help=constants.STRIP_INPUT_HELP,
                        metavar='INPUT')
    parser.add_argument('output',
                        help=constants.STRIP_OUTPUT_HELP,
                        metavar='OUTPUT')
Esempio n. 23
0
def generate_align_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to generate aligned
    sequences from a set of results."""
    parser = subparsers.add_parser(
        "align",
        description=constants.ALIGN_DESCRIPTION,
        epilog=constants.ALIGN_EPILOG,
        formatter_class=ParagraphFormatter,
        help=constants.ALIGN_HELP,
    )
    parser.set_defaults(func=align_results)
    utils.add_common_arguments(parser)
    parser.add_argument("-m", "--minimum", default=20, help=constants.ALIGN_MINIMUM_SIZE_HELP, type=int)
    utils.add_corpus_arguments(parser)
    parser.add_argument("output", help=constants.ALIGN_OUTPUT_HELP, metavar="OUTPUT")
    parser.add_argument("results", help=constants.RESULTS_RESULTS_HELP, metavar="RESULTS")
Esempio n. 24
0
def generate_diff_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to make a diff
    query."""
    parser = subparsers.add_parser(
        "diff",
        description=constants.DIFF_DESCRIPTION,
        epilog=constants.DIFF_EPILOG,
        formatter_class=ParagraphFormatter,
        help=constants.DIFF_HELP,
    )
    parser.set_defaults(func=ngram_diff)
    group = parser.add_mutually_exclusive_group()
    group.add_argument("-a", "--asymmetric", help=constants.ASYMMETRIC_HELP, metavar="LABEL")
    utils.add_common_arguments(parser)
    utils.add_db_arguments(parser)
    utils.add_corpus_arguments(parser)
    utils.add_query_arguments(parser)
Esempio n. 25
0
def generate_catalogue_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to generate and save
    a catalogue file."""
    parser = subparsers.add_parser('catalogue',
                                   description=constants.CATALOGUE_DESCRIPTION,
                                   epilog=constants.CATALOGUE_EPILOG,
                                   formatter_class=ParagraphFormatter,
                                   help=constants.CATALOGUE_HELP)
    utils.add_common_arguments(parser)
    parser.set_defaults(func=generate_catalogue)
    parser.add_argument('corpus',
                        help=constants.DB_CORPUS_HELP,
                        metavar='CORPUS')
    utils.add_query_arguments(parser)
    parser.add_argument('-l',
                        '--label',
                        default='',
                        help=constants.CATALOGUE_LABEL_HELP)
Esempio n. 26
0
def generate_work_against_corpus_subparser(subparsers):
    parser = subparsers.add_parser(
        "work-against-corpus",
        description=constants.TACL_HELPER_AGAINST_DESCRIPTION,
        help=constants.TACL_HELPER_AGAINST_HELP,
        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
    )
    parser.set_defaults(func=work_against_corpus)
    utils.add_common_arguments(parser)
    utils.add_db_arguments(parser)
    utils.add_corpus_arguments(parser)
    parser.add_argument(
        "a_works", help=constants.TACL_HELPER_AGAINST_A_HELP, metavar="FILES_LIST", type=argparse.FileType("r")
    )
    parser.add_argument(
        "b_works", help=constants.TACL_HELPER_AGAINST_B_HELP, metavar="CORPUS_FILES_LIST", type=argparse.FileType("r")
    )
    parser.add_argument("output_dir", help=constants.TACL_HELPER_OUTPUT, metavar="OUTPUT_DIR")
Esempio n. 27
0
def generate_diff_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to make a diff
    query."""
    parser = subparsers.add_parser('diff',
                                   description=constants.DIFF_DESCRIPTION,
                                   epilog=constants.DIFF_EPILOG,
                                   formatter_class=ParagraphFormatter,
                                   help=constants.DIFF_HELP)
    parser.set_defaults(func=ngram_diff)
    group = parser.add_mutually_exclusive_group()
    group.add_argument('-a',
                       '--asymmetric',
                       help=constants.ASYMMETRIC_HELP,
                       metavar='LABEL')
    utils.add_common_arguments(parser)
    utils.add_db_arguments(parser)
    utils.add_corpus_arguments(parser)
    utils.add_query_arguments(parser)
Esempio n. 28
0
def generate_ngrams_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to add n-grams data
    to the data store."""
    parser = subparsers.add_parser(
        "ngrams",
        description=constants.NGRAMS_DESCRIPTION,
        epilog=constants.NGRAMS_EPILOG,
        formatter_class=ParagraphFormatter,
        help=constants.NGRAMS_HELP,
    )
    parser.set_defaults(func=generate_ngrams)
    utils.add_common_arguments(parser)
    parser.add_argument(
        "-c", "--catalogue", dest="catalogue", help=constants.NGRAMS_CATALOGUE_HELP, metavar="CATALOGUE"
    )
    utils.add_db_arguments(parser)
    utils.add_corpus_arguments(parser)
    parser.add_argument("min_size", help=constants.NGRAMS_MINIMUM_HELP, metavar="MINIMUM", type=int)
    parser.add_argument("max_size", help=constants.NGRAMS_MAXIMUM_HELP, metavar="MAXIMUM", type=int)
Esempio n. 29
0
def generate_highlight_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to highlight a witness'
    text with its matches in a result."""
    parser = subparsers.add_parser(
        "highlight",
        description=constants.HIGHLIGHT_DESCRIPTION,
        epilog=constants.HIGHLIGHT_EPILOG,
        formatter_class=ParagraphFormatter,
        help=constants.HIGHLIGHT_HELP,
    )
    parser.set_defaults(func=highlight_text)
    utils.add_common_arguments(parser)
    parser.add_argument("-m", "--minus-ngrams", metavar="NGRAMS", help=constants.HIGHLIGHT_MINUS_NGRAMS_HELP)
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument("-n", "--ngrams", action="append", metavar="NGRAMS", help=constants.HIGHLIGHT_NGRAMS_HELP)
    group.add_argument("-r", "--results", metavar="RESULTS", help=constants.HIGHLIGHT_RESULTS_HELP)
    parser.add_argument("-l", "--label", action="append", metavar="LABEL", help=constants.HIGHLIGHT_LABEL_HELP)
    utils.add_corpus_arguments(parser)
    parser.add_argument("base_name", help=constants.HIGHLIGHT_BASE_NAME_HELP, metavar="BASE_NAME")
    parser.add_argument("output", metavar="OUTPUT", help=constants.REPORT_OUTPUT_HELP)
Esempio n. 30
0
def generate_align_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to generate aligned
    sequences from a set of results."""
    parser = subparsers.add_parser('align',
                                   description=constants.ALIGN_DESCRIPTION,
                                   epilog=constants.ALIGN_EPILOG,
                                   formatter_class=ParagraphFormatter,
                                   help=constants.ALIGN_HELP)
    parser.set_defaults(func=align_results)
    utils.add_common_arguments(parser)
    parser.add_argument('-m',
                        '--minimum',
                        default=20,
                        help=constants.ALIGN_MINIMUM_SIZE_HELP,
                        type=int)
    utils.add_corpus_arguments(parser)
    parser.add_argument('output',
                        help=constants.ALIGN_OUTPUT_HELP,
                        metavar='OUTPUT')
    parser.add_argument('results',
                        help=constants.RESULTS_RESULTS_HELP,
                        metavar='RESULTS')
Esempio n. 31
0
def generate_excise_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to excise n-grams from
    witnesses."""
    parser = subparsers.add_parser('excise',
                                   description=constants.EXCISE_DESCRIPTION,
                                   help=constants.EXCISE_HELP)
    parser.set_defaults(func=excise)
    utils.add_common_arguments(parser)
    parser.add_argument('ngrams',
                        metavar='NGRAMS',
                        help=constants.EXCISE_NGRAMS_HELP)
    parser.add_argument('replacement',
                        metavar='REPLACEMENT',
                        help=constants.EXCISE_REPLACEMENT_HELP)
    parser.add_argument('output',
                        metavar='OUTPUT',
                        help=constants.EXCISE_OUTPUT_HELP)
    utils.add_corpus_arguments(parser)
    parser.add_argument('works',
                        metavar='WORK',
                        help=constants.EXCISE_WORKS_HELP,
                        nargs='+')
Esempio n. 32
0
def generate_prepare_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to prepare source XML
    files for stripping."""
    parser = subparsers.add_parser(
        "prepare",
        description=constants.PREPARE_DESCRIPTION,
        epilog=constants.PREPARE_EPILOG,
        formatter_class=ParagraphFormatter,
        help=constants.PREPARE_HELP,
    )
    parser.set_defaults(func=prepare_xml)
    utils.add_common_arguments(parser)
    parser.add_argument(
        "-s",
        "--source",
        dest="source",
        choices=constants.TEI_SOURCE_CHOICES,
        default=constants.TEI_SOURCE_CBETA_GITHUB,
        help=constants.PREPARE_SOURCE_HELP,
        metavar="SOURCE",
    )
    parser.add_argument("input", help=constants.PREPARE_INPUT_HELP, metavar="INPUT")
    parser.add_argument("output", help=constants.PREPARE_OUTPUT_HELP, metavar="OUTPUT")
Esempio n. 33
0
def generate_prepare_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to prepare source XML
    files for stripping."""
    parser = subparsers.add_parser('prepare',
                                   description=constants.PREPARE_DESCRIPTION,
                                   epilog=constants.PREPARE_EPILOG,
                                   formatter_class=ParagraphFormatter,
                                   help=constants.PREPARE_HELP)
    parser.set_defaults(func=prepare_xml)
    utils.add_common_arguments(parser)
    parser.add_argument('-s',
                        '--source',
                        dest='source',
                        choices=constants.TEI_SOURCE_CHOICES,
                        default=constants.TEI_SOURCE_CBETA_GITHUB,
                        help=constants.PREPARE_SOURCE_HELP,
                        metavar='SOURCE')
    parser.add_argument('input',
                        help=constants.PREPARE_INPUT_HELP,
                        metavar='INPUT')
    parser.add_argument('output',
                        help=constants.PREPARE_OUTPUT_HELP,
                        metavar='OUTPUT')
Esempio n. 34
0
def generate_highlight_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to highlight a witness'
    text with its matches in a result."""
    parser = subparsers.add_parser('highlight',
                                   description=constants.HIGHLIGHT_DESCRIPTION,
                                   epilog=constants.HIGHLIGHT_EPILOG,
                                   formatter_class=ParagraphFormatter,
                                   help=constants.HIGHLIGHT_HELP)
    parser.set_defaults(func=highlight_text)
    utils.add_common_arguments(parser)
    parser.add_argument('-m',
                        '--minus-ngrams',
                        metavar='NGRAMS',
                        help=constants.HIGHLIGHT_MINUS_NGRAMS_HELP)
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-n',
                       '--ngrams',
                       action='append',
                       metavar='NGRAMS',
                       help=constants.HIGHLIGHT_NGRAMS_HELP)
    group.add_argument('-r',
                       '--results',
                       metavar='RESULTS',
                       help=constants.HIGHLIGHT_RESULTS_HELP)
    parser.add_argument('-l',
                        '--label',
                        action='append',
                        metavar='LABEL',
                        help=constants.HIGHLIGHT_LABEL_HELP)
    utils.add_corpus_arguments(parser)
    parser.add_argument('base_name',
                        help=constants.HIGHLIGHT_BASE_NAME_HELP,
                        metavar='BASE_NAME')
    parser.add_argument('output',
                        metavar='OUTPUT',
                        help=constants.REPORT_OUTPUT_HELP)
Esempio n. 35
0
def generate_results_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to manipulate CSV
    results data."""
    parser = subparsers.add_parser(
        "results",
        description=constants.RESULTS_DESCRIPTION,
        epilog=constants.RESULTS_EPILOG,
        formatter_class=ParagraphFormatter,
        help=constants.RESULTS_HELP,
    )
    utils.add_common_arguments(parser)
    parser.set_defaults(func=results)
    be_group = parser.add_argument_group("bifurcated extend")
    be_group.add_argument(
        "-b",
        "--bifurcated-extend",
        dest="bifurcated_extend",
        metavar="CORPUS",
        help=constants.RESULTS_BIFURCATED_EXTEND_HELP,
    )
    be_group.add_argument(
        "--max-be-count",
        dest="bifurcated_extend_size",
        help=constants.RESULTS_BIFURCATED_EXTEND_MAX_HELP,
        metavar="COUNT",
        type=int,
    )
    parser.add_argument(
        "-c", "--catalogue", dest="catalogue", help=constants.RESULTS_CATALOGUE_HELP, metavar="CATALOGUE"
    )
    parser.add_argument("-e", "--extend", dest="extend", help=constants.RESULTS_EXTEND_HELP, metavar="CORPUS")
    parser.add_argument(
        "--min-count", dest="min_count", help=constants.RESULTS_MINIMUM_COUNT_HELP, metavar="COUNT", type=int
    )
    parser.add_argument(
        "--max-count", dest="max_count", help=constants.RESULTS_MAXIMUM_COUNT_HELP, metavar="COUNT", type=int
    )
    parser.add_argument(
        "--min-count-work",
        dest="min_count_work",
        help=constants.RESULTS_MINIMUM_COUNT_WORK_HELP,
        metavar="COUNT",
        type=int,
    )
    parser.add_argument(
        "--max-count-work",
        dest="max_count_work",
        help=constants.RESULTS_MAXIMUM_COUNT_WORK_HELP,
        metavar="COUNT",
        type=int,
    )
    parser.add_argument(
        "--min-size", dest="min_size", help=constants.RESULTS_MINIMUM_SIZE_HELP, metavar="SIZE", type=int
    )
    parser.add_argument(
        "--max-size", dest="max_size", help=constants.RESULTS_MAXIMUM_SIZE_HELP, metavar="SIZE", type=int
    )
    parser.add_argument(
        "--min-works", dest="min_works", help=constants.RESULTS_MINIMUM_WORK_HELP, metavar="COUNT", type=int
    )
    parser.add_argument(
        "--max-works", dest="max_works", help=constants.RESULTS_MAXIMUM_WORK_HELP, metavar="COUNT", type=int
    )
    parser.add_argument("--ngrams", dest="ngrams", help=constants.RESULTS_NGRAMS_HELP, metavar="NGRAMS")
    parser.add_argument("--reciprocal", action="store_true", help=constants.RESULTS_RECIPROCAL_HELP)
    parser.add_argument("--reduce", action="store_true", help=constants.RESULTS_REDUCE_HELP)
    parser.add_argument("--remove", help=constants.RESULTS_REMOVE_HELP, metavar="LABEL", type=str)
    parser.add_argument("--sort", action="store_true", help=constants.RESULTS_SORT_HELP)
    utils.add_tokenizer_argument(parser)
    parser.add_argument("-z", "--zero-fill", dest="zero_fill", help=constants.RESULTS_ZERO_FILL_HELP, metavar="CORPUS")
    parser.add_argument("results", help=constants.RESULTS_RESULTS_HELP, metavar="RESULTS")
Esempio n. 36
0
def generate_results_subparser(subparsers):
    """Adds a sub-command parser to `subparsers` to manipulate CSV
    results data."""
    parser = subparsers.add_parser('results',
                                   description=constants.RESULTS_DESCRIPTION,
                                   epilog=constants.RESULTS_EPILOG,
                                   formatter_class=ParagraphFormatter,
                                   help=constants.RESULTS_HELP)
    utils.add_common_arguments(parser)
    parser.set_defaults(func=results)
    be_group = parser.add_argument_group('bifurcated extend')
    be_group.add_argument('-b',
                          '--bifurcated-extend',
                          dest='bifurcated_extend',
                          metavar='CORPUS',
                          help=constants.RESULTS_BIFURCATED_EXTEND_HELP)
    be_group.add_argument('--max-be-count',
                          dest='bifurcated_extend_size',
                          help=constants.RESULTS_BIFURCATED_EXTEND_MAX_HELP,
                          metavar='COUNT',
                          type=int)
    parser.add_argument('-e',
                        '--extend',
                        dest='extend',
                        help=constants.RESULTS_EXTEND_HELP,
                        metavar='CORPUS')
    parser.add_argument('--excise',
                        help=constants.RESULTS_EXCISE_HELP,
                        metavar='NGRAM',
                        type=str)
    parser.add_argument('--min-count',
                        dest='min_count',
                        help=constants.RESULTS_MINIMUM_COUNT_HELP,
                        metavar='COUNT',
                        type=int)
    parser.add_argument('--max-count',
                        dest='max_count',
                        help=constants.RESULTS_MAXIMUM_COUNT_HELP,
                        metavar='COUNT',
                        type=int)
    parser.add_argument('--min-count-work',
                        dest='min_count_work',
                        help=constants.RESULTS_MINIMUM_COUNT_WORK_HELP,
                        metavar='COUNT',
                        type=int)
    parser.add_argument('--max-count-work',
                        dest='max_count_work',
                        help=constants.RESULTS_MAXIMUM_COUNT_WORK_HELP,
                        metavar='COUNT',
                        type=int)
    parser.add_argument('--min-size',
                        dest='min_size',
                        help=constants.RESULTS_MINIMUM_SIZE_HELP,
                        metavar='SIZE',
                        type=int)
    parser.add_argument('--max-size',
                        dest='max_size',
                        help=constants.RESULTS_MAXIMUM_SIZE_HELP,
                        metavar='SIZE',
                        type=int)
    parser.add_argument('--min-works',
                        dest='min_works',
                        help=constants.RESULTS_MINIMUM_WORK_HELP,
                        metavar='COUNT',
                        type=int)
    parser.add_argument('--max-works',
                        dest='max_works',
                        help=constants.RESULTS_MAXIMUM_WORK_HELP,
                        metavar='COUNT',
                        type=int)
    parser.add_argument('--ngrams',
                        dest='ngrams',
                        help=constants.RESULTS_NGRAMS_HELP,
                        metavar='NGRAMS')
    parser.add_argument('--reciprocal',
                        action='store_true',
                        help=constants.RESULTS_RECIPROCAL_HELP)
    parser.add_argument('--reduce',
                        action='store_true',
                        help=constants.RESULTS_REDUCE_HELP)
    parser.add_argument('--remove',
                        help=constants.RESULTS_REMOVE_HELP,
                        metavar='LABEL',
                        type=str)
    parser.add_argument('--sort',
                        action='store_true',
                        help=constants.RESULTS_SORT_HELP)
    utils.add_tokenizer_argument(parser)
    parser.add_argument('-z',
                        '--zero-fill',
                        dest='zero_fill',
                        help=constants.RESULTS_ZERO_FILL_HELP,
                        metavar='CORPUS')
    parser.add_argument('results',
                        help=constants.RESULTS_RESULTS_HELP,
                        metavar='RESULTS')
    unsafe_group = parser.add_argument_group(
        constants.RESULTS_UNSAFE_GROUP_TITLE,
        constants.RESULTS_UNSAFE_GROUP_DESCRIPTION)
    unsafe_group.add_argument('--add-label-count',
                              action='store_true',
                              help=constants.RESULTS_ADD_LABEL_COUNT_HELP)
    unsafe_group.add_argument('--add-label-work-count',
                              action='store_true',
                              help=constants.RESULTS_ADD_LABEL_WORK_COUNT_HELP)
    unsafe_group.add_argument('--collapse-witnesses',
                              action='store_true',
                              help=constants.RESULTS_COLLAPSE_WITNESSES_HELP)
    unsafe_group.add_argument('--group-by-ngram',
                              dest='group_by_ngram',
                              help=constants.RESULTS_GROUP_BY_NGRAM_HELP,
                              metavar='CATALOGUE')
    unsafe_group.add_argument('--group-by-witness',
                              action='store_true',
                              help=constants.RESULTS_GROUP_BY_WITNESS_HELP)