Exemple #1
0
    def test_surname_only_person_with_accent(self):
        """
        Test that persons with accents in their names are reduced to surnames.
        """

        postprocessor = WikipediaPostprocessor(surname_only=True)
        participants = ['Bertrand Traoré']
        self.assertEqual(['Traore'], postprocessor.postprocess(participants))
Exemple #2
0
    def test_surname_only_person_with_multiple_components(self):
        """
        Test that persons with multiple components in their names retain all but the first component.
        """

        postprocessor = WikipediaPostprocessor(surname_only=True)
        participants = ['David De Gea']
        self.assertEqual(['De Gea'], postprocessor.postprocess(participants))
Exemple #3
0
    def test_surname_only_person_no_name(self):
        """
        Test that persons are reduced to surnames only if they have a first name.
        """

        postprocessor = WikipediaPostprocessor(surname_only=True)
        participants = ['Pedro (footballer, born 1987)']
        self.assertEqual(['Pedro'], postprocessor.postprocess(participants))
Exemple #4
0
    def test_surname_only_person_word(self):
        """
        Test that persons are reduced to surnames only if the surname is not a word.
        """

        postprocessor = WikipediaPostprocessor(surname_only=True)
        participants = ['Martin Terrier']
        self.assertEqual(participants, postprocessor.postprocess(participants))
Exemple #5
0
    def test_remove_brackets(self):
        """
        Test that participants with brackets lose them when the parameter is set.
        """

        postprocessor = WikipediaPostprocessor(remove_brackets=True)
        participants = ['Apple (Company)']
        self.assertEqual(['Apple'], postprocessor.postprocess(participants))
Exemple #6
0
    def test_surname_only_person(self):
        """
        Test that persons are reduced to surnames.
        """

        postprocessor = WikipediaPostprocessor(surname_only=True)
        participants = ['Memphis Depay']
        self.assertEqual(['Depay'], postprocessor.postprocess(participants))
Exemple #7
0
    def test_surname_only_location(self):
        """
        Test that locations are retained without any changes.
        """

        postprocessor = WikipediaPostprocessor(surname_only=True)
        participants = ['Hell, California']
        self.assertEqual(set(participants),
                         set(postprocessor.postprocess(participants)))
Exemple #8
0
    def test_surname_only_organization(self):
        """
        Test that organizations are retained without any changes.
        """

        postprocessor = WikipediaPostprocessor(surname_only=True)
        participants = ['Apple Inc.']
        self.assertEqual(set(participants),
                         set(postprocessor.postprocess(participants)))
Exemple #9
0
    def test_remove_brackets_no_brackets(self):
        """
        Test that participants without brackets are returned as given.
        """

        postprocessor = WikipediaPostprocessor(remove_brackets=True)
        participants = ['Apple Inc.']
        self.assertEqual(['Apple Inc.'],
                         postprocessor.postprocess(participants))
Exemple #10
0
    def test_retain_french_accents(self):
        """
        Test that French accents are retained in French participant names when removal is disabled.
        """

        postprocessor = WikipediaPostprocessor(remove_accents=False,
                                               surname_only=False)
        participants = ['Moussa Dembélé']
        self.assertEqual(['Moussa Dembélé'],
                         postprocessor.postprocess(participants))
Exemple #11
0
    def test_remove_french_accents(self):
        """
        Test that French accents are removed from French participant names.
        """

        postprocessor = WikipediaPostprocessor(remove_accents=True,
                                               surname_only=False)
        participants = ['Moussa Dembélé']
        self.assertEqual(['Moussa Dembele'],
                         postprocessor.postprocess(participants))
Exemple #12
0
    def test_surname_only_person_with_brackets(self):
        """
        Test that persons with brackets in their names are reduced to surnames without the brackets.
        """

        postprocessor = WikipediaPostprocessor(surname_only=True)
        participants = [
            'Ronaldo (Brazilian footballer)',
            'Moussa Dembélé (French footballer)'
        ]
        self.assertEqual(['Ronaldo', 'Dembele'],
                         postprocessor.postprocess(participants))
Exemple #13
0
    def test_trivial_postprocessing(self):
        """
        Test that when no configuration is given, the participants are returned as given.
        """

        postprocessor = WikipediaPostprocessor(remove_accents=False,
                                               remove_brackets=False,
                                               surname_only=False)
        participants = [
            'Youssouf Koné (footballer, born 1995)',
            'Pedro (footballer, born 1987)'
        ]
        self.assertEqual(set(participants),
                         set(postprocessor.postprocess(participants)))
Exemple #14
0
    def test_retain_germanic_accents(self):
        """
        Test that Germanic accents are retained in Germanic participant names when removal is disabled.
        """

        postprocessor = WikipediaPostprocessor(remove_accents=False,
                                               surname_only=False)
        participants = [
            'Erling Braut Håland', 'Anel Ahmedhodžić', 'Alexander Kačaniklić',
            'Robin Söder'
        ]
        self.assertEqual([
            'Erling Braut Håland', 'Anel Ahmedhodžić', 'Alexander Kačaniklić',
            'Robin Söder'
        ], postprocessor.postprocess(participants))
Exemple #15
0
    def test_remove_germanic_accents(self):
        """
        Test that Germanic accents are removed from Germanic participant names.
        """

        postprocessor = WikipediaPostprocessor(remove_accents=True,
                                               surname_only=False)
        participants = [
            'Erling Braut Håland', 'Anel Ahmedhodžić', 'Alexander Kačaniklić',
            'Robin Söder'
        ]
        self.assertEqual([
            'Erling Braut Haland', 'Anel Ahmedhodzic', 'Alexander Kacaniklic',
            'Robin Soder'
        ], postprocessor.postprocess(participants))