示例#1
0
def main():

    amr_file = r'test-data/amrs.txt'
    sentence_file = r'test-data/sentences.txt'
    if len(sys.argv) > 2:
        amr_file = sys.argv[1]
        sentence_file = sys.argv[2]

    failed_amrs = Counter()
    failed_words = Counter()
    with open(sentence_file, 'r', encoding='utf8') as f1:
        sentences = [s for s in re.split('\n\s*\n', f1.read()) if s]
        with open(amr_file, 'r', encoding='utf8') as f2:
            for i, amr in enumerate(AMR.amr_iter(f2.read())):
                print('#' + str(i + 1))
                words = sentences[i].strip().split()
                amr = AMR(amr)
                # test_rules(amr, words)
                alignments, amr_unal, words_unal = align_amr(amr, words)
                print('# AMR:')
                print('\n'.join('# ' + l for l in str(amr).split('\n')))
                print('# Sentence:')
                print('# ' + ' '.join(words))
                print('# Alignments:')
                for a in alignments:
                    print('#', a.readible())
                for a in alignments:
                    print(a)
                print()
示例#2
0
def main():
    input_file = r'test-data/amrs.txt'
    if len(sys.argv) > 1:
        input_file = sys.argv[1]

    with open(input_file, 'r', encoding='utf8') as f:
        for amr in AMR.amr_iter(f.read()):
            amr = AMR_Latex.latex(amr)
            print(amr)
            print()
示例#3
0
def main():
    input_file = r'test-data/amrs.txt'
    ids = True if '-x' in sys.argv else False
    if len(sys.argv) > 1:
        input_file = sys.argv[-1]

    with open(input_file, 'r', encoding='utf8') as f:
        for amr in AMR.amr_iter(f.read()):
            amr = AMR_HTML.html(amr, ids)
            print(amr)
            print()