I have XML which looks like this:
<para id="0">
<se lang="hi">काकेशिया में तब लड़ाई</se>
<se lang="ru">потом боевые действия на Кавказе</se>
</para>
<para id="1">
...
</para>
<para id="2">
...
</para>
and I want to tokenize the devanagari text by using iNLTK library and get a file which looks like this:
<para id="0">
<se lang="hi">
<w>काकेशिया</w>
<w>में</w>
<w>तब</w>
<w>लड़ाई</w>
</se>
<se lang="ru">потом боевые действия на Кавказе</se>
</para>
<para id="1">
...
</para>
<para id="2">
...
</para>
I understand how to tokenize the sentence:
paras = body.getElementsByTagName('para')
for para in paras:
devanagari = para.getElementsByTagName('se')[1].childNodes[0].nodeValue
print(tokenize(devanagari, 'hi'))
but what I don't know is how to make childnodes xml <w>...</w>
for each word and write it into the XML
How can I do that by using xml.etree.ElementTree?