<commit_before># Unit Tests for French conjugation
# Author: <NAME>

import unittest
import languages.french as French
from functools import partial
from category import Category

class TestFrenchConjugator(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.test_verbs = ['parler', 'finir', 'vendre']

    def test_present(self):
        expected = [['parle', 'parles', 'parle',
                     'parlons', 'parlez', 'parlent'],
                    ['finis', 'finis', 'finit',
                     'finissons', 'finissez', 'finissent'],
                    ['vends', 'vends', 'vend',
                     'vendons', 'vendez', 'vendent']]

        self.run_sub_tests(expected, 'Présent')

    def test_imperfect(self):
        expected = [['parlais', 'parlais', 'parlait',
                     'parlions', 'parliez', 'parlaient'],
                    ['finissais', 'finissais', 'finissait',
                     'finissions', 'finissiez', 'finissaient'],
                    ['vendais', 'vendais', 'vendait',
                     'vendions', 'vendiez', 'vendaient']]

        self.run_sub_tests(expected, 'Imparfait')

    def test_passé_simple(self):
        expected = [['parlai', 'parlas', 'parla',
                     'parlâmes', 'parlâtes', 'parlèrent'],
                    ['finis', 'finis', 'finit',
                     'finîmes', 'finîtes', 'finirent'],
                    ['vendis', 'vendis', 'vendit',
                     'vendîmes', 'vendîtes', 'vendirent']]

        self.run_sub_tests(expected, 'Passé simple')

    def test_future(self):
        expected = [['parlerai', 'parleras', 'parlera',
                     'parlerons', 'parlerez', 'parleront'],
                    ['finirai', 'finiras', 'finira',
                     'finirons', 'finirez', 'finiront'],
                    ['vendrai', 'vendras', 'vendra',
                     'vendrons', 'vendrez', 'vendront']]

        self.run_sub_tests(expected, 'Futur')

    def test_conditional(self):
        expected = [['parlerais', 'parlerais', 'parlerait',
                     'parlerions', 'parleriez', 'parleraient'],
                    ['finirais', 'finirais', 'finirait',
                     'finirions', 'finiriez', 'finiraient'],
                    ['vendrais', 'vendrais', 'vendrait',
                     'vendrions', 'vendriez', 'vendraient']]

        self.run_sub_tests(expected, 'Conditionnel')

    def test_present_subjunctive(self):
        expected = [['parle', 'parles', 'parle',
                     'parlions', 'parliez', 'parlent'],
                    ['finisse', 'finisses', 'finisse',
                     'finissions', 'finissiez', 'finissent'],
                    ['vende', 'vendes', 'vende',
                     'vendions', 'vendiez', 'vendent']]

        self.run_sub_tests(expected, 'Présent subjonctif')

    def test_imperfect_subjunctive(self):
        expected = [['parlasse', 'parlasses', 'parlât',
                     'parlassions', 'parlassiez', 'parlassent'],
                    ['finisse', 'finisses', 'finît',
                     'finissions', 'finissiez', 'finissent'],
                    ['vendisse', 'vendisses', 'vendît',
                     'vendissions', 'vendissiez', 'vendissent']]

        self.run_sub_tests(expected, 'Imparfait subjonctif')

    def run_sub_tests(self, expected, tense):
        conj = partial(French.construct_stem_and_ending, tense=tense)
        for i, verb in enumerate(TestFrenchConjugator.test_verbs):
            with self.subTest(verb=verb):
                [self.assertEqual(expect, actual) for expect, actual in
                 zip(expected[i], conj(verb))]


class TestConjugatorVerbsThatStartWithVowel(unittest.TestCase):
    def test_verb_starts_with_a(self):
        conj = French.construct_inflection('abandonner', 'Présent').fps
        pronoun, verb = conj[0], conj[1]
        self.assertEqual("j'abandonne", '{0}{1}'.format(pronoun, verb))

class TestClozeDeletionOutputRules(unittest.TestCase):

    def test_cloze_normal(self):
        expected = Category._make(['je {{c1::parle::parler, Présent}}',
                    'tu {{c1::parles::parler, Présent}}',
                    'il/elle/on {{c1::parle::parler, Présent}}',
                    'nous {{c1::parlons::parler, Présent}}',
                    'vous {{c1::parlez::parler, Présent}}',
                    'ils/elles {{c1::parlent::parler, Présent}}'])

        conj = French.construct_inflection('parler', 'Présent')
        actual = French.output_cloze('parler', 'Présent', conj)
        with self.subTest():
            self.assertEqual(expected.fps, actual.fps)
            self.assertEqual(expected.sps, actual.sps)
            self.assertEqual(expected.tps, actual.tps)<commit_msg>replaced manual unpacking of tuple with pythonic version<commit_after># Unit Tests for French conjugation
# Author: <NAME>

import unittest
import languages.french as French
from functools import partial
from category import Category

class TestFrenchConjugator(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.test_verbs = ['parler', 'finir', 'vendre']

    def test_present(self):
        expected = [['parle', 'parles', 'parle',
                     'parlons', 'parlez', 'parlent'],
                    ['finis', 'finis', 'finit',
                     'finissons', 'finissez', 'finissent'],
                    ['vends', 'vends', 'vend',
                     'vendons', 'vendez', 'vendent']]

        self.run_sub_tests(expected, 'Présent')

    def test_imperfect(self):
        expected = [['parlais', 'parlais', 'parlait',
                     'parlions', 'parliez', 'parlaient'],
                    ['finissais', 'finissais', 'finissait',
                     'finissions', 'finissiez', 'finissaient'],
                    ['vendais', 'vendais', 'vendait',
                     'vendions', 'vendiez', 'vendaient']]

        self.run_sub_tests(expected, 'Imparfait')

    def test_passé_simple(self):
        expected = [['parlai', 'parlas', 'parla',
                     'parlâmes', 'parlâtes', 'parlèrent'],
                    ['finis', 'finis', 'finit',
                     'finîmes', 'finîtes', 'finirent'],
                    ['vendis', 'vendis', 'vendit',
                     'vendîmes', 'vendîtes', 'vendirent']]

        self.run_sub_tests(expected, 'Passé simple')

    def test_future(self):
        expected = [['parlerai', 'parleras', 'parlera',
                     'parlerons', 'parlerez', 'parleront'],
                    ['finirai', 'finiras', 'finira',
                     'finirons', 'finirez', 'finiront'],
                    ['vendrai', 'vendras', 'vendra',
                     'vendrons', 'vendrez', 'vendront']]

        self.run_sub_tests(expected, 'Futur')

    def test_conditional(self):
        expected = [['parlerais', 'parlerais', 'parlerait',
                     'parlerions', 'parleriez', 'parleraient'],
                    ['finirais', 'finirais', 'finirait',
                     'finirions', 'finiriez', 'finiraient'],
                    ['vendrais', 'vendrais', 'vendrait',
                     'vendrions', 'vendriez', 'vendraient']]

        self.run_sub_tests(expected, 'Conditionnel')

    def test_present_subjunctive(self):
        expected = [['parle', 'parles', 'parle',
                     'parlions', 'parliez', 'parlent'],
                    ['finisse', 'finisses', 'finisse',
                     'finissions', 'finissiez', 'finissent'],
                    ['vende', 'vendes', 'vende',
                     'vendions', 'vendiez', 'vendent']]

        self.run_sub_tests(expected, 'Présent subjonctif')

    def test_imperfect_subjunctive(self):
        expected = [['parlasse', 'parlasses', 'parlât',
                     'parlassions', 'parlassiez', 'parlassent'],
                    ['finisse', 'finisses', 'finît',
                     'finissions', 'finissiez', 'finissent'],
                    ['vendisse', 'vendisses', 'vendît',
                     'vendissions', 'vendissiez', 'vendissent']]

        self.run_sub_tests(expected, 'Imparfait subjonctif')

    def run_sub_tests(self, expected, tense):
        conj = partial(French.construct_stem_and_ending, tense=tense)
        for i, verb in enumerate(TestFrenchConjugator.test_verbs):
            with self.subTest(verb=verb):
                [self.assertEqual(expect, actual) for expect, actual in
                 zip(expected[i], conj(verb))]


class TestConjugatorVerbsThatStartWithVowel(unittest.TestCase):
    def test_verb_starts_with_a(self):
        conj = French.construct_inflection('abandonner', 'Présent').fps
        pronoun, verb = conj
        self.assertEqual("j'abandonne", '{0}{1}'.format(pronoun, verb))

class TestClozeDeletionOutputRules(unittest.TestCase):

    def test_cloze_normal(self):
        expected = Category._make(['je {{c1::parle::parler, Présent}}',
                    'tu {{c1::parles::parler, Présent}}',
                    'il/elle/on {{c1::parle::parler, Présent}}',
                    'nous {{c1::parlons::parler, Présent}}',
                    'vous {{c1::parlez::parler, Présent}}',
                    'ils/elles {{c1::parlent::parler, Présent}}'])

        conj = French.construct_inflection('parler', 'Présent')
        actual = French.output_cloze('parler', 'Présent', conj)
        with self.subTest():
            self.assertEqual(expected.fps, actual.fps)
            self.assertEqual(expected.sps, actual.sps)
            self.assertEqual(expected.tps, actual.tps)
{'fraction_non_alphanumeric': 0.15282008192416763, 'fraction_numerical': 0.001890557714525785, 'mean_word_length': 2.2028254288597378, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3690647', 'n_tokens_mistral': 3118, 'n_tokens_neox': 2949, 'n_words': 543}