AMR-gs icon indicating copy to clipboard operation
AMR-gs copied to clipboard

Post-processing fails if sentence is quoted

Open iamanigeeit opened this issue 3 years ago • 0 comments

Problem The parser will output unbalanced quotes if the the input sentence is quoted. This leads post-processing failure with error penman.DecodeError: Expected ":" or "/" at position XXX

Example .pred file

# ::id 8553
# ::snt "@united got it right with the safety demonstration! Corporate but funny, reserved but NOT CORNY  as a… http://t.co/lwOtKIEKGU"
# ::tokens ["''", "@united", "got", "it", "right", "with", "the", "safety", "demonstration", "!", "Corporate", "but", "funny", ",", "reserved", "but", "NOT", "CORNY", "as", "a", "...", "http://t.co/lwOtKIEKGU\""]
# ::lemmas ["''", "@united", "get", "it", "right", "with", "the", "safety", "demonstration", "!", "corporate", "but", "funny", ",", "reserved", "but", "NOT", "CORNY", "as", "a", "...", "http://t.co/lwotkiekgu\""]
# ::pos_tags ["''", "VBN", "VBD", "PRP", "RB", "IN", "DT", "NN", "NN", ".", "JJ", "CC", "JJ", ",", "JJ", "CC", "NNP", "NNP", "IN", "DT", ":", "NN"]
# ::ner_tags ["O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "O", "URL"]
# ::abstract_map {}
(c0 / multi-sentence
    :snt1 (c1 / contrast
              :ARG1 (c3 / right-06
                        :ARG1 (c7 / it)
                        :ARG2 (c8 / demonstrate
                                  :ARG1 (c10 / safe)))
              :ARG1 (c4 / funny
                        :domain (c9 / string-entity
                                    :value "http://t.co/lwotkiekgu"")))
    :snt2 (c2 / contrast
              :ARG1 (c5 / corporate)
              :ARG2 (c6 / corny
                        :domain c9)))

Note the two quotes at the end of :value "http://t.co/lwotkiekgu"".

./postprocess_2.0.sh sample.txt.pred
multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/home/perry/anaconda3/envs/stog/lib/python3.6/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/home/perry/anaconda3/envs/stog/lib/python3.6/multiprocessing/pool.py", line 44, in mapstar
    return list(map(*args))
  File "/home/perry/PycharmProjects/phd/AMR-gs-master/stog/data/dataset_readers/amr_parsing/postprocess/postprocess.py", line 16, in postprocess2
    for amr in nr.restore_file(file_path):
  File "/home/perry/PycharmProjects/phd/AMR-gs-master/stog/data/dataset_readers/amr_parsing/postprocess/node_restore.py", line 19, in restore_file
    for amr in AMRIO.read(file_path):
  File "/home/perry/PycharmProjects/phd/AMR-gs-master/stog/data/dataset_readers/amr_parsing/io.py", line 48, in read
    amr.graph = AMRGraph.decode(' '.join(graph_lines))
  File "/home/perry/PycharmProjects/phd/AMR-gs-master/stog/data/dataset_readers/amr_parsing/amr.py", line 640, in decode
    _graph = amr_codec.decode(raw_graph_string)
  File "/home/perry/anaconda3/envs/stog/lib/python3.6/site-packages/penman.py", line 172, in decode
    span, data = self._decode_penman_node(s)
  File "/home/perry/anaconda3/envs/stog/lib/python3.6/site-packages/penman.py", line 405, in _decode_penman_node
    span, data = self._decode_penman_node(s, pos=pos)
  File "/home/perry/anaconda3/envs/stog/lib/python3.6/site-packages/penman.py", line 405, in _decode_penman_node
    span, data = self._decode_penman_node(s, pos=pos)
  File "/home/perry/anaconda3/envs/stog/lib/python3.6/site-packages/penman.py", line 405, in _decode_penman_node
    span, data = self._decode_penman_node(s, pos=pos)
  File "/home/perry/anaconda3/envs/stog/lib/python3.6/site-packages/penman.py", line 427, in _decode_penman_node
    raise DecodeError('Expected ":" or "/"', string=s, pos=pos)
penman.DecodeError: Expected ":" or "/" at position 375

Workaround Eliminate quotes before inputting sentences.

iamanigeeit avatar Feb 21 '21 17:02 iamanigeeit