I have list of tuple within a list which is list of sentence, pos tagged corresponding word in tuple.
[[('This', 'DT'), ('is', 'VBZ'), ('the', 'DT'), ('house', 'NN')],
[('This', 'DT'), ('is', 'VBZ'), ('the', 'DT'), ('car', 'NN')],
[('This', 'DT'), ('is', 'VBZ'), ('the', 'DT'), ('dog', 'NN')]]
I want to write it into text file. Expected output :
This DT
is VBZ
the DT
house NN
This DT
is VBZ
the DT
car NN
This DT
is VBZ
the DT
dog NN
After writing this into a file
with open("new.txt","w") as wf:
wf.write('\n'.join(' '.join(str(x) for x in tu) for tu in tag) )
The file I got something like this which not expected output.
('This', 'DT') ('is', 'VBZ') ('the', 'DT') ('house', 'NN')
('This', 'DT') ('is', 'VBZ') ('the', 'DT') ('car', 'NN')
How can I achieve the result mentioned above: sentences separated by '\n'(gap between columns(sentences)) and word's pos tag in corresponding second column. I searched a bit but no luck!. Kindly help please? :)