XML to dict(d)
Stefan Behnel
stefan_ml at behnel.de
Mon Jan 31 08:08:02 EST 2011
Daniel Stender, 31.01.2011 13:45:
> we are trying to convert a Sanskrit dictionary which is in a "homegrown" XML format into dict(d),
> the input file goes like this:
>
> <cut>
> <H2><h><hc3>200</hc3><key1>akAlikam</key1><hc1>2</hc1><key2>a-kAlikam</key2></h><body>
> <lex>ind.</lex> <c>immediately</c> <ls>MBh.</ls> </body><tail><mul/> <MW>000173</MW> <pc>2,2</pc>
> <L>266</L></tail></H2>
> <H2><h><hc3>110</hc3><key1>akAlya</key1><hc1>2</hc1><key2>a-kAlya</key2></h><body> <lex>mfn.</lex>
> <c>unseasonable.</c> </body><tail><mul/> <MW>000174</MW> <pc>2,2</pc> <L>267</L></tail></H2>
> <H1><h><hc3>110</hc3><key1>akAsAra</key1><hc1>1</hc1><key2>a-kAsAra</key2></h><body> <lex>m.</lex>
> <c>N._of_a_teacher</c> <ls>BhP.</ls> </body><tail><mul/> <MW>000175</MW> <pc>2,2</pc>
> <L>268</L></tail></H1>
> <H1><h><hc3>110</hc3><key1>akiYcana</key1><hc1>1</hc1><key2>a-kiYcana</key2></h><body>
> <lex>mfn.</lex> <c>without_anything_,_utterly_destitute</c> </body><tail><pc>2,2</pc>
> <L>269</L></tail></H1>
> <H1A><h><hc3>100</hc3><key1>akiYcana</key1><hc1>1</hc1><key2>a-kiYcana</key2></h><body> <lex
> type="inh">mfn.</lex> <c>disinterested</c> </body><tail><pc>2,2</pc> <L>270</L></tail></H1A>
> <H1B><h><hc3>110</hc3><key1>akiYcana</key1><hc1>1</hc1><key2>a-kiYcana</key2></h><body>
> <lex>n.</lex> <c>that_which_is_worth_nothing.</c> </body><tail><MW>000176</MW> <pc>2,2</pc>
> <L>271</L></tail></H1B>
> <H3><h><hc3>110</hc3><key1>akiYcanatA</key1><hc1>3</hc1><key2>a-kiYcana--tA</key2></h><body>
> <lex>f.</lex> <OR/>
> <c>voluntary_poverty_<p>as_practised_by_<as0>Jaina</as0><as1><s>jEna</s></as1>_ascetics</p>.</c>
> </body><tail><MW>000177</MW> <pc>2,2</pc> <L>272</L></tail></H3>
> </cut>
>
> I've found that there is the library python-dictdlib for concatenating dict dictionaries, what would
> be the best way to "de-XML" the source file?
How do you want to the dict to look like?
Stefan
More information about the Python-list
mailing list