Updated the program name to apertium-talk
[apertium.git] / apertium-en-de / wordmirror / printnounxml.py
blobd974d9aa232f6b8975afaabed139d952900fd295
1 # Francis Tyers
3 from WordMirror import WordMirrorNounInflection;
5 def print_xml(inflection, noun): #{
7 casesymbols = { "Nominative": "nom", "Dative": "dat", "Accusative": "acc", "Genitive": "gen" };
9 numbersymbols = { "No Article": "sg", "Plural No Article": "pl" };
11 print ' <pardef n="' + noun + '__n">';
13 gender = inflection['Gender'];
14 if(gender == 'n'): #{
15 gender = 'nt';
18 for key in inflection.keys(): #{
19 if(key in ['Gender', 'Word Type', 'Plural']): #{
20 continue;
23 for (case, infl1) in inflection[key].items(): #{
24 if(key not in numbersymbols.keys()): #{
25 continue;
28 for infl2 in infl1.split("/"): #{
29 print ' <e> <!-- ' + key + ' -->';
30 print ' <p>';
32 if(infl2 == noun): #{
33 print ' <l/>';
35 if(infl2 != noun): #{
36 print ' <l>' + infl2.replace(noun, '') + '</l>';
39 print ' <r><s n="n"/><s n="' + gender + '"/><s n="' + casesymbols[case] +'"/><s n="' + numbersymbols[key] + '"/></r>';
40 print ' </p>';
41 print ' </e>';
46 print ' </pardef>';
48 def usage(): #{
49 print 'python printnounxml.py <noun>';
52 if __name__ == "__main__": #{
53 import sys;
55 if(len(sys.argv) <= 1): #{
56 usage();
57 sys.exit();
59 inflect = WordMirrorNounInflection(sys.argv[1]);
60 print_xml(inflect, sys.argv[1]);