User:MewBot/eoverbformbot.py

#!/usr/bin/env python
#coding: utf-8

# Copyright CodeCat 2010, 2011

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# This script is based on parts from
# http://en.wiktionary.org/wiki/User:SemperBlottoBot/verbs

import wikipedia, re
from formbot import *


class EOVerbFormBot(GenericFormBot):
	"""A form bot for Esperanto verb forms."""
	
	def __init__(self, head, cleanupCat, simulation = False, force = False, verbose = False):
		GenericFormBot.__init__(
			self, head, ['eo-conj'], 'eo', 'Esperanto',
			cleanupCat, simulation, force, verbose)
	
	
	def generateEntries(self, template, params):
		"""Overrides base class method."""
		
		if template == 'eo-conj':
			return self.conjugate(params)
		else:
			return None
	

	def conjugate(self, params):
		"""Conjugate an Esperanto verb using {{eo-conj}}."""
		
		stem = params[1]
		
		forms = {}
		
		forms[stem + 'as'] = '===Verb===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|as}}'
		forms[stem + 'is'] = '===Verb===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|is}}'
		forms[stem + 'os'] = '===Verb===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|os}}'
		forms[stem + 'u' ] = '===Verb===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|u}}'
		forms[stem + 'us'] = '===Verb===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|us}}'
		
		forms[stem + 'anta'] = '===Adjective===\n{{eo-part-sublemma|' + stem + '|anta}}\n\n# {{eo-form of|' + stem + '|anta}}'
		forms[stem + 'inta'] = '===Adjective===\n{{eo-part-sublemma|' + stem + '|inta}}\n\n# {{eo-form of|' + stem + '|inta}}'
		forms[stem + 'onta'] = '===Adjective===\n{{eo-part-sublemma|' + stem + '|onta}}\n\n# {{eo-form of|' + stem + '|onta}}'
		forms[stem + 'antan' ] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|antan}}'
		forms[stem + 'antaj' ] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|antaj}}'
		forms[stem + 'antajn'] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|antajn}}'
		forms[stem + 'intan' ] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|intan}}'
		forms[stem + 'intaj' ] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|intaj}}'
		forms[stem + 'intajn'] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|intajn}}'
		forms[stem + 'ontan' ] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|ontan}}'
		forms[stem + 'ontaj' ] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|ontaj}}'
		forms[stem + 'ontajn'] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|ontajn}}'
		
		forms[stem + 'anto'] = '===Noun===\n{{eo-part-sublemma|' + stem + '|anto}}\n\n# {{eo-form of|' + stem + '|anto}}'
		forms[stem + 'into'] = '===Noun===\n{{eo-part-sublemma|' + stem + '|into}}\n\n# {{eo-form of|' + stem + '|into}}'
		forms[stem + 'onto'] = '===Noun===\n{{eo-part-sublemma|' + stem + '|onto}}\n\n# {{eo-form of|' + stem + '|onto}}'
		forms[stem + 'anton' ] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|anton}}'
		forms[stem + 'antoj' ] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|antoj}}'
		forms[stem + 'antojn'] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|antojn}}'
		forms[stem + 'inton' ] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|inton}}'
		forms[stem + 'intoj' ] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|intoj}}'
		forms[stem + 'intojn'] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|intojn}}'
		forms[stem + 'onton' ] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|onton}}'
		forms[stem + 'ontoj' ] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|ontoj}}'
		forms[stem + 'ontojn'] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|ontojn}}'
		
		forms[stem + 'ante'] = '===Adverb===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|ante}}'
		forms[stem + 'inte'] = '===Adverb===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|inte}}'
		forms[stem + 'onte'] = '===Adverb===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|onte}}'
		
		if not 'intr' in params:
			forms[stem + 'ata'] = '===Adjective===\n{{eo-part-sublemma|' + stem +  '|ata}}\n\n# {{eo-form of|' + stem +  '|ata}}'
			forms[stem + 'ita'] = '===Adjective===\n{{eo-part-sublemma|' + stem +  '|ita}}\n\n# {{eo-form of|' + stem +  '|ita}}'
			forms[stem + 'ota'] = '===Adjective===\n{{eo-part-sublemma|' + stem +  '|ota}}\n\n# {{eo-form of|' + stem +  '|ota}}'
			forms[stem + 'atan' ] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|atan}}'
			forms[stem + 'ataj' ] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|ataj}}'
			forms[stem + 'atajn'] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|atajn}}'
			forms[stem + 'itan' ] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|itan}}'
			forms[stem + 'itaj' ] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|itaj}}'
			forms[stem + 'itajn'] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|itajn}}'
			forms[stem + 'otan' ] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|otan}}'
			forms[stem + 'otaj' ] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|otaj}}'
			forms[stem + 'otajn'] = '===Adjective===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|otajn}}'
			
			forms[stem + 'ato'] = '===Noun===\n{{eo-part-sublemma|' + stem + '|ato}}\n\n# {{eo-form of|' + stem + '|ato}}'
			forms[stem + 'ito'] = '===Noun===\n{{eo-part-sublemma|' + stem + '|ito}}\n\n# {{eo-form of|' + stem + '|ito}}'
			forms[stem + 'oto'] = '===Noun===\n{{eo-part-sublemma|' + stem + '|oto}}\n\n# {{eo-form of|' + stem + '|oto}}'
			forms[stem + 'aton' ] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|aton}}'
			forms[stem + 'atoj' ] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|atoj}}'
			forms[stem + 'atojn'] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|atojn}}'
			forms[stem + 'iton' ] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|iton}}'
			forms[stem + 'itoj' ] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|itoj}}'
			forms[stem + 'itojn'] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|itojn}}'
			forms[stem + 'oton' ] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|oton}}'
			forms[stem + 'otoj' ] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|otoj}}'
			forms[stem + 'otojn'] = '===Noun===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|otojn}}'
			
			forms[stem + 'ate'] = '===Adverb===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|ate}}'
			forms[stem + 'ite'] = '===Adverb===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|ite}}'
			forms[stem + 'ote'] = '===Adverb===\n{{head|eo}}\n\n# {{eo-form of|' + stem + '|ote}}'
		
		return forms