def main():
    global args
    parser = parse_args()
    args = parser.parse_args()

    if args.reader == "gold":
        d = gold_reader(args.inp_fp)
    elif args.reader == "openiefive":
        predicted = OpenieFiveReader()
        predicted.read(args.inp_fp)
        d = dict()
        for sent, exts in predicted.oie.items():
            temp = []
            for ext in exts:
                temp.append(ext.args[0] + '\t' + ext.pred + '\t' +
                            '\t'.join(ext.args[1:]))
            d[sent] = temp
        # ipdb.set_trace()
    elif args.reader == "openiefour":
        predicted = OpenieFourReader()
        predicted.read(args.inp_fp)
        d = dict()
        ipdb.set_trace()
        for sent, exts in predicted.oie.items():
            temp = []
            for ext in exts:
                temp.append(ext.args[0] + '\t' + ext.pred + '\t' +
                            '\t'.join(ext.args[1:]))
            d[sent] = temp
    elif args.reader == "readable":
        d = readable_reader(args.inp_fp)
        # ipdb.set_trace()

    sent_with_and = 0
    ext_split = 0
    for sent, exts in d.items():
        words = sent.split(' ')
        if "and" in words:
            sent_with_and += 1
            try:
                pos = words.index("and")
            except:
                ipdb.set_trace()
            phrase = ' '.join(words[pos - 1:pos + 1])
            ext_split += 1
            for ext in exts:
                if phrase in ext:
                    ext_split -= 1
                    break

    print("total_sent={} sent_with_and={} split_sent={} %splits={}".format(
        len(d.items()), sent_with_and, ext_split,
        np.round(100 * ext_split / sent_with_and, 2)))
Example #2
0
File: carb.py Project: yyht/openie6
        predicted.read(args['--props'])

    if args['--ollie']:
        predicted = OllieReader()
        predicted.read(args['--ollie'])

    if args['--reverb']:
        predicted = ReVerbReader()
        predicted.read(args['--reverb'])

    if args['--clausie']:
        predicted = ClausieReader()
        predicted.read(args['--clausie'])

    if args['--openiefour']:
        predicted = OpenieFourReader()
        predicted.read(args['--openiefour'])

    if args['--openiefive']:
        predicted = OpenieFiveReader()
        predicted.read(args['--openiefive'])

    if args['--benchmarkGold']:
        predicted = BenchmarkGoldReader()
        predicted.read(args['--benchmarkGold'])

    if args['--tabbed']:
        predicted = TabReader()
        predicted.read(args['--tabbed'])

    if args['--allennlp']: