示例#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)
示例#2
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)
示例#3
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
示例#4
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)
示例#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
示例#6
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)
示例#7
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")
示例#8
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')
示例#9
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')
示例#10
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")
示例#11
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")
示例#12
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)
示例#13
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)
示例#14
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")
示例#15
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)
示例#16
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")
示例#17
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)
示例#18
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)
示例#19
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)
示例#20
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')
示例#21
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='+')
示例#22
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)