import re
def main():
inputPage = open('./dataInput.txt','r')
outputPage = open('./wikiInput.txt','w')
data = inputPage.read()
meaningSearchR = re.compile(r'=([^=]+)=([^=]+)=([^=]*)=*\n')
#meaningSearchR = re.compile(r'##([^#]+)#([^#]+)#([^#]*)#*\n')
phraseSearchR = re.compile(r'([^,]+),[\s]*')
wordSearchR = re.compile(r'([^\s]+)')
for word, meaning1, meaning2 in meaningSearchR.findall(data):
if meaning2=="":
meaning2 = meaning1
meaning1 = ""
meanings1 = phraseSearchR.split(meaning1);
meanings2 = phraseSearchR.split(meaning2);
outputPage.write('{{-start-}}<!--\'\'\''+word+'\'\'\'-->\n')
outputPage.write('==മലയാളം==\n')
if meaning1 != "":
outputPage.write('===നാമം===\n')
for meaning in meanings1:
if meaning != "":
outputPage.write('#')
words = wordSearchR.split(meaning)
for word in words:
if word != "" and word != " ":
outputPage.write('[['+word+']] ')
outputPage.write('\n')
if meaning2 != "":
outputPage.write('===തർജ്ജമകൾ===\n[[ഇംഗ്ലീഷ്]]:\n')
for meaning in meanings2:
if meaning != "":
outputPage.write('#')
words = wordSearchR.split(meaning)
for word in words:
if word != "" and word != " ":
outputPage.write('[['+word+']] ')
outputPage.write('\n')
outputPage.write('{{-stop-}}\n')
if __name__ == "__main__":
try:
main()
finally:
print ""