Closed abhinavkaul95 closed 3 years ago
Looks like parse_sents is making a parse tree like this:
'[Text=lady CharacterOffsetBegin=4 CharacterOffsetEnd=8 PartOfSpeech=NN Lemma=lady] [Text=with CharacterOffsetBegin=9 CharacterOffsetEnd=13 PartOfSpeech=IN Lemma=with] [Text=the CharacterOffsetBegin=14 CharacterOffsetEnd=17 PartOfSpeech=DT Lemma=the] [Text=blue CharacterOffsetBegin=18 CharacterOffsetEnd=22 PartOfSpeech=JJ Lemma=blue] [Text=shirt CharacterOffsetBegin=23 CharacterOffsetEnd=28 PartOfSpeech=NN Lemma=shirt] (ROOT (NP (NP (DT the) (NN lady)) (PP (IN with) (NP (DT the) (JJ blue) (NN shirt)))))'
but parse_attrs is expecting a tree like this:
(ROOT (NP (NP (DT the) (NN lady)) (PP (IN with) (NP (DT the) (JJ blue) (NN shirt)))))'
and that is why the error.
Hi! I met this issue as well, so how to fix it?
Quick hack could be just find the first instance of '(':
index = output['parsetree'].find('(')
output['parsetree'] = output['parsetree'][index:]
While executing the following command:
python parse_atts.py --dataset refcoco --splitBy unc
I am getting the following error:
`Traceback (most recent call last): File "parse_atts.py", line 57, in main attparser.reset(parse) File "/media/disk/user/abhinav/refer-parser2/pyutils/attparser/cocoParser.py", line 21, in reset BaseParser.reset(self, parse) File "/media/disk/user/abhinav/refer-parser2/pyutils/attparser/baseParser.py", line 29, in reset self._tree = Tree.fromstring(parse['parsetree']) File "/media/disk/user/abhinav/MAttNet/venv/lib/python3.7/site-packages/nltk/tree.py", line 687, in fromstring cls._parse_error(s, match, open_b) File "/media/disk/user/abhinav/MAttNet/venv/lib/python3.7/site-packages/nltk/tree.py", line 738, in _parse_error raise ValueError(msg) ValueError: Tree.read(): expected '(' but got '[Text=lady' at index 0. "[Text=lady..." ^
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "parse_atts.py", line 85, in
main(params)
File "parse_atts.py", line 63, in main
sent['left'] = attparser.leftWords()
File "/media/disk/user/abhinav/refer-parser2/pyutils/attparser/baseParser.py", line 89, in leftWords
all_wds = [word[0] for word in self._words]
AttributeError: 'CocoParser' object has no attribute '_words'`
Following is my requirements.txt: