Created
February 28, 2012 18:55
-
-
Save vssun/1934371 to your computer and use it in GitHub Desktop.
വിക്ഷണറിയിലെ ആവശ്യത്തിനു വേണ്ടി - താളിന്റെ പേരും നിർവചനവും അടങ്ങിയിട്ടുള്ള ഫയലിൽ നിന്ന് താളുകൾ നിർമ്മിക്കാൻ.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
""" | |
വിക്ഷണറിയിലെ ആവശ്യത്തിനു വേണ്ടി - താളിന്റെ പേരും നിർവചനവും അടങ്ങിയിട്ടുള്ള ഫയലിൽ നിന്ന് താളുകൾ നിർമ്മിക്കാൻ. | |
നിർമ്മിച്ചത്: സുനിൽ വി.എസ്., സരയുവിനൊപ്പം | |
തിയതി: 2012-02-28 | |
""" | |
import wikipedia | |
import pagegenerators | |
import codecs | |
#പ്രധാന പ്രോഗ്രാം ഇവിടെ തുടങ്ങുന്നു. | |
#ആവശ്യത്തിനനുസരിച്ച് മാറ്റങ്ങൾ ഇതിനു താഴെ വരുത്തുക | |
siteFamily = 'wiktionary' | |
siteLangCode = 'ml' | |
pageListPairFileName = "pagelist.txt" | |
#ആവശ്യത്തിനനുസരിച്ച് മാറ്റങ്ങൾ ഇതിനു മുകളിൽ വരുത്തുക | |
pageDefinitionPairs = [] | |
myFile=codecs.open(pageListPairFileName,encoding='utf-8') | |
myPageName = None | |
for myLine in myFile: | |
if myPageName: | |
pageDefinitionPairs.append([myPageName, myLine]) | |
myPageName = None | |
else: | |
myPageName = myLine | |
lastPage=myPageName | |
myFile.close() | |
if myPageName: | |
wikipedia.output(u'WARNING: file %s contains odd number of links' % pageListPairFileName) | |
else: | |
wikipedia.output(u'No problem') | |
wikiSite = wikipedia.Site(code=siteLangCode, fam=siteFamily) | |
for pair in pageDefinitionPairs: | |
myPage=wikipedia.Page(site=wikiSite,title=pair[0][:-1]) | |
wikipedia.output(u"Output page" + myPage.title() + u"") | |
myText=pair[1] | |
if myText[-1]=="\n": | |
myText=myText[:-1] | |
wikipedia.output(u"== മലയാളം ==\n# [[" + myText + u"]]") | |
myPage.put(u"== മലയാളം ==\n# [[" + myText + u"]]") | |
wikipedia.stopme() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment