Ejemplo n.º 1
0
def convert_trees(results_dict, feature, align, paths, failtok, best, backoff):
    if not align:
        results = sorted(results_dict.items(), key=lambda x:x[0])
        lines = []
        for iid, item in results:
            if feature == "short-derivation":
                lines.extend(item)
                continue

            for reading in item[:best]:
                features = reading_features(reading, feature)
                if features is not None:
                    lines.append(features)
    else:
        if backoff is not None:
            backoffs = extract_backoff_items(backoff)

        lines = []
        for iid in delphin.get_profile_ids(*paths):
            try:
                features = reading_features(results_dict[iid][0], feature)
                lines.append(features)
            except IndexError:
                if backoff is not None:
                    lines.append(tagged[iid])
                else:
                    lines.append(failtok)

    if feature in MULTILINE_FEATURES:
        sep = '\n\n'
    else:
        sep = '\n'
    
    return sep.join(lines)
Ejemplo n.º 2
0
def main():
    arg = argparser().parse_args()
    query = "select i-id where p-id = {}".format(arg.pid)
    tsdb_results = delphin.tsdb_query(query, arg.profile)
    gold_iids = set(int(x) for x in tsdb_results.split())
    all_iids = delphin.get_profile_ids(arg.profile)
    predicted_iids = get_predicted_iids(arg)
    print evaluate(predicted_iids, gold_iids, len(all_iids))