<commit_before>#!/usr/bin/python
# -*- coding: utf-8  -*-
"""
Categorize people according to their year of birth and death.

The following parameters are supported:

&params;

-dry              If given, doesn't do any real changes, but only shows
                  what would have been changed.

All other parameters will be regarded as part of the title of a single page,
and the bot will only work on that single page.
"""
__version__ = '$Id$'
import wikipedia as pywikibot
import catlib, pagegenerators, re

# This is required for the text that is shown when you run this script
# with the parameter -help.
docuReplacements = {
    '&params;': pagegenerators.parameterHelp
}

class BirthCatBot:
    # Edit summary message that should be used.
    # NOTE: Put a good description here, and add translations, if possible!
    msg = {
        'fi': u'Botti lisäsi: %s',
    }

    msgNewCat = {
        'fi': u'Botti loi uuden luokan',
    }

    # TODO: Implement BC years
    dateFormat = {
        'fi': ur'(?:\[*\d+\.\s+\S+kuuta\]*,?\s+)?\[*(\d+)\]*',
        }
    
    birthDeathCats = {
        'fi': {
            u'Vuonna %s syntyneet' : {
                'templates' :{
                    u'Syntymäaika ja ikä': 3,
                    u'Syntymä- ja kuolinaika': 3,
                    u'Kuolinaika ja ikä': 3,
                    },
                're': [
                    re.compile(ur'syntynyt\s*=\s*' + dateFormat['fi']),
                    re.compile(ur"'''[^)]*(?:\bs\.\s+|,\s+|\(|(?<!&ndash);\s+)" + dateFormat['fi']),
                    ],
                'newcat': lambda yr: u'{{Syntymävuosiluokka|%s|%s}}\n\n[[en:Category:%s births]]' % (yr[:-1], yr[-1], yr)
                },
            u'Vuonna %s kuolleet' : {
                'templates' :{
                    u'Syntymä- ja kuolinaika': 6,
                    u'Kuolinaika ja ikä': 6,
                    },
                're': [
                    re.compile(ur'kuollut\s*=\s*' + dateFormat['fi']),
                    re.compile(ur"'''[^()]*\((?:[^)]|\([^)]*\))*(?:\bk\.\s+|(?:[–—-]|&ndash;)\s*)" + dateFormat['fi']),
                    ],
                'newcat': lambda yr: u'{{Kuolinvuosiluokka|%s|%s}}\n\n[[en:Category:%s deaths]]' % (yr[:-1], yr[-1], yr)
                }
            }
        }
    
    def __init__(self, generator, dry):
        """
        Constructor. Parameters:
            * generator - The page generator that determines on which pages
                          to work on.
            * dry       - If True, doesn't do any real changes, but only shows
                          what would have been changed.
        """
        self.generator = generator
        self.dry = dry
        self.lang = pywikibot.getSite().lang
        
        # Get the correct localized parameters
        self.site = pywikibot.getSite()
        self.summary = pywikibot.translate(self.site, self.msg)
        self.summaryNewCat = pywikibot.translate(self.site, self.msgNewCat)
        self.bdCats = pywikibot.translate(self.site, self.birthDeathCats)

        self.defaultSortMatcher = None        <commit_msg>Tunnistetaan myös auki kirjoitetut "syntynyt" ja "kuollut".<commit_after>#!/usr/bin/python
# -*- coding: utf-8  -*-
"""
Categorize people according to their year of birth and death.

The following parameters are supported:

&params;

-dry              If given, doesn't do any real changes, but only shows
                  what would have been changed.

All other parameters will be regarded as part of the title of a single page,
and the bot will only work on that single page.
"""
__version__ = '$Id$'
import wikipedia as pywikibot
import catlib, pagegenerators, re

# This is required for the text that is shown when you run this script
# with the parameter -help.
docuReplacements = {
    '&params;': pagegenerators.parameterHelp
}

class BirthCatBot:
    # Edit summary message that should be used.
    # NOTE: Put a good description here, and add translations, if possible!
    msg = {
        'fi': u'Botti lisäsi: %s',
    }

    msgNewCat = {
        'fi': u'Botti loi uuden luokan',
    }

    # TODO: Implement BC years
    dateFormat = {
        'fi': ur'(?:\[*\d+\.\s+\S+kuuta\]*,?\s+)?\[*(\d+)\]*',
        }
    
    birthDeathCats = {
        'fi': {
            u'Vuonna %s syntyneet' : {
                'templates' :{
                    u'Syntymäaika ja ikä': 3,
                    u'Syntymä- ja kuolinaika': 3,
                    u'Kuolinaika ja ikä': 3,
                    },
                're': [
                    re.compile(ur'syntynyt\s*=\s*' + dateFormat['fi']),
                    re.compile(ur"'''[^)]*(?:\b(?:s\.|syntynyt)\s+|,\s+|\(|(?<!&ndash);\s+)" + dateFormat['fi']),
                    ],
                'newcat': lambda yr: u'{{Syntymävuosiluokka|%s|%s}}\n\n[[en:Category:%s births]]' % (yr[:-1], yr[-1], yr)
                },
            u'Vuonna %s kuolleet' : {
                'templates' :{
                    u'Syntymä- ja kuolinaika': 6,
                    u'Kuolinaika ja ikä': 6,
                    },
                're': [
                    re.compile(ur'kuollut\s*=\s*' + dateFormat['fi']),
                    re.compile(ur"'''[^()]*\((?:[^)]|\([^)]*\))*(?:\b(?:k\.|kuollut)\s+|(?:[–—-]|&ndash;)\s*)" + dateFormat['fi']),
                    ],
                'newcat': lambda yr: u'{{Kuolinvuosiluokka|%s|%s}}\n\n[[en:Category:%s deaths]]' % (yr[:-1], yr[-1], yr)
                }
            }
        }
    
    def __init__(self, generator, dry):
        """
        Constructor. Parameters:
            * generator - The page generator that determines on which pages
                          to work on.
            * dry       - If True, doesn't do any real changes, but only shows
                          what would have been changed.
        """
        self.generator = generator
        self.dry = dry
        self.lang = pywikibot.getSite().lang
        
        # Get the correct localized parameters
        self.site = pywikibot.getSite()
        self.summary = pywikibot.translate(self.site, self.msg)
        self.summaryNewCat = pywikibot.translate(self.site, self.msgNewCat)
        self.bdCats = pywikibot.translate(self.site, self.birthDeathCats)

        self.defaultSortMatcher = None        
{'fraction_non_alphanumeric': 0.15119784229731872, 'fraction_numerical': 0.0031730921783277802, 'mean_word_length': 1.7242869490060502, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1911295', 'n_tokens_mistral': 2098, 'n_tokens_neox': 1973, 'n_words': 492}