I have a grammar tag producing nltk block which is,
sent_text = nltk.sent_tokenize(text) # this gives us a list of sentences
# now loop over each sentence and tokenize it separately
for sentence in sent_text:
tokenized_text = nltk.word_tokenize(sentence)
tagged = nltk.pos_tag(tokenized_text)
for word, tag in tagged:
print(tag)
This gives me the following output,
DT
JJ
NN
NN
VBD
IN
DT
JJ
NN
However, I want the output to single lined like
DT JJ NN NN VBD IN DT JJ NN
How do I do this?