Closed hristost closed 3 years ago
@hristost Hi, in PTB, parentheses are normalized as -LRB-/-RRB-
. So replacing (/)
with -LRB-/-RRB-
may lead to better results.
>>> print(parser.predict(['Supar', '-LRB-', 'in', 'particular', ',', 'the', 'tree', 'binarization', '-RRB-', 'crashes', 'when', 'parentheses', 'are', 'present', 'in', 'input', '.'],verbose=False).sentences[0].trees.pformat(30))
(TOP
(S
(NP
(NP (_ Supar))
(PRN
(_ -LRB-)
(PP
(_ in)
(NP (_ particular)))
(_ ,)
(NP
(_ the)
(_ tree)
(_ binarization))
(_ -RRB-)))
(VP
(_ crashes)
(SBAR
(WHADVP (_ when))
(S
(NP
(_ parentheses))
(VP
(_ are)
(ADJP
(_ present)
(PP
(_ in)
(NP
(_ input))))))))
(_ .)))
>>> print(parser.predict(['Supar', '[', 'in', 'particular', ',', 'the', 'tree', 'binarization', ']', 'crashes', 'when', 'parentheses', 'are', 'present', 'in', 'input', '.'],verbose=False).sentences[0].trees.pformat(30))
(TOP
(S
(S
(NP
(NP (_ Supar))
(_ [))
(PP
(_ in)
(NP (_ particular))))
(_ ,)
(NP
(NP
(_ the)
(_ tree)
(_ binarization))
(_ ]))
(VP
(_ crashes)
(SBAR
(WHADVP (_ when))
(S
(NP
(_ parentheses))
(VP
(_ are)
(ADJP
(_ present)
(PP
(_ in)
(NP
(_ input))))))))
(_ .)))
I will fix this issue in the next release. Thank you for your problem.
@hristost Fixed. Refer to the code below (available in SuPar v1.0.1
).
https://github.com/yzhangcs/parser/blob/2bb44dc9dafa212e90086cd2da580165c2609fa4/supar/utils/transform.py#L499-L532
The code below:
crashes when there are parentheses in the input. Backtrace as follows:
This seems related to #64 and #59. I tried editing the code to not index into empty arrays, but i ended up either discarding tokens, or triggering an error inside
nltk.Tree.collapse_unary
.When I replaced the parentheses with square brackets (
Supar [the parser] crashes when parentheses are present in input.
), parsing worked but produced weird result -- "the parser" moved inside the verb phrase:Has the model been trained on text that uses parentheses? Or are we expected to strip out text inside parentheses and parse it separately?