#!/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.orghttps://dictious.com/en/User:SemperBlottoBot/verbs
import wikipedia, re
from formbot import *
class NLAdjectiveFormBot(GenericFormBot):
"""A form bot for Dutch adjective forms."""
def __init__(self, head, cleanupCat, simulation = False, force = False, verbose = False):
GenericFormBot.__init__(
self, head, , 'nl', 'Dutch',
cleanupCat, simulation, force, verbose)
def generateEntries(self, template, params):
"""Overrides base class method."""
if template == 'nl-decl-adj':
return self.decline(params)
elif template == 'nl-decl-adj-nc':
params = '-'
params = '-'
return self.decline(params)
else:
return None
def decline(self, params):
"""Decline a Dutch adjective using {{nl-decl-adj}}."""
# Make a dictionary of lists of the entries, with the word as key
# That way we automatically group cases where two forms are identical
forms = {}
if 1 not in params or params != '-':
infl = params.get(1, self._head + 'e')
forms.setdefault(infl, ).append('{{nl-adj-form|f=infl|' + self._head + '}}')
else:
infl = self._head + 'e'
if 2 not in params or params != '-':
part = params.get(2, self._head + 's')
forms.setdefault(part, ).append('{{nl-adj-form|f=part|' + self._head + '}}')
else:
part = self._head + 's'
if 3 not in params or params != '-':
comp = params.get(3, infl + 'r')
forms.setdefault(comp, ).append('{{nl-adj-form|d=comp|' + self._head + '}}')
if 1 not in params or params != '-':
inflComp = comp + 'e'
forms.setdefault(inflComp, ).append('{{nl-adj-form|f=infl|d=comp|' + self._head + '}}')
partComp = comp + 's'
forms.setdefault(partComp, ).append('{{nl-adj-form|f=part|d=comp|' + self._head + '}}')
if 4 not in params or params != '-':
sup = params.get(4, part + 't')
forms.setdefault(sup, ).append('{{nl-adj-form|d=sup|' + self._head + '}}')
inflSup = sup + 'e'
forms.setdefault(inflSup, ).append('{{nl-adj-form|f=infl|d=sup|' + self._head + '}}')
forms = self.zipEntries(forms, '==={0}===\n{{{{head|{1}|{2} form}}}}\n\n'.format('Adjective', self._langCode, 'adjective'))
return forms