示例#1
0
def compare(grammar, arg):
    split = arg.paths.index('@')
    pathsA = arg.paths[:split]
    pathsB = arg.paths[split+1:]
    readingA = delphin.get_profile_results(pathsA, best=arg.best, gold=arg.gold, 
                                            cutoff=arg.cutoff, grammar=grammar)
    resultsB = delphin.get_profile_results(pathsB, best=arg.best, gold=arg.gold,
                                             cutoff=arg.cutoff, grammar=grammar)
    return compare_trees(resultsA, resultsB, arg.feature)
示例#2
0
def get_results(grammar, arg):
    lextypes = not (arg.feature in NONTDL_FEATURES or arg.le)
    cache = (arg.command == 'convert' and arg.feature == 'derivation')

    if arg.command == 'count' and arg.feature == 'types':
        typifier = config.TYPIFIERBIN
    else:
        typifier = None

    if len(arg.paths) == 0 or arg.parse:
        if len(arg.paths) == 0:
            # read input from standard input
            lines = sys.stdin.readlines()
        else:
            # read lines from from list of input files
            lines = []
            for path in arg.paths:
                with open(path) as f:
                    lines.extend(f.readlines())
        if arg.cutoff is not None:
            lines = lines[:cutoff]
            
        if arg.feature == "short-derivation":
            results = delphin.get_short_label_results(
                lines, grammar, best=arg.best, fragments=arg.fragments,
                ace_path=config.ACEBIN)
        else:
            results = delphin.get_text_results(
                lines, grammar, best=arg.best, ace_path=config.ACEBIN,
                lextypes=lextypes, typifier=typifier, fragments=arg.fragments,
                cache=cache)
    else:
        results = delphin.get_profile_results(
            arg.paths, best=arg.best, gold=arg.gold, cutoff=arg.cutoff, 
            grammar=grammar, lextypes=lextypes, typifier=typifier,
            pspans=arg.pspans, condition=arg.tsql, cache=cache)
    return results