I use following code to print result of a parse tree in python NLTK.
import os
import nltk
from nltk.parse import stanford
from nltk.tokenize import sent_tokenize
os.environ['STANFORD_PARSER'] = '/home/gadheyan/Project/stanford-parser-full-2014-08-27'
os.environ['STANFORD_MODELS'] = '/home/gadheyan/Project/stanford-parser-full-2014-08-27'
parser = stanford.StanfordParser(model_path="/home/gadheyan/Project/stanford-parser-full-2014-08-27/stanford-parser-3.4.1-models/edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz")
sentences = parser.raw_parse_sents(["A rare black squirrel has become a regular visitor to a suburban garden"])
print sentences
I expected the result as follows:
(ROOT
(S
(NP (DT A) (JJ rare) (JJ black) (NN squirrel))
(VP
(VBZ has)
(VP
(VBN become)
(NP (DT a) (JJ regular) (NN visitor))
(PP (TO to) (NP (DT a) (JJ suburban) (NN garden)))))))
But i got the result as
<listiterator object at 0x7f6ed5c30890>
Why does that happen?