コード例 #1
0
    def test_is_person_pattern4(self):
        """
        Test that an article with pattern 2 is correctly captured as a person.
        """

        page = 'Valentina Shevchenko (fighter)'
        classes = info.is_person(page)
        self.assertTrue(classes[page])
コード例 #2
0
    def test_is_person_pattern2(self):
        """
        Test that an article with pattern 2 is correctly captured as a person.
        """

        page = 'Dario Benedetto'
        classes = info.is_person(page)
        self.assertTrue(classes[page])
コード例 #3
0
    def test_is_person(self):
        """
        Test checking whether an individual article is about a person.
        """

        page = 'Rudi Garcia'
        classes = info.is_person(page)
        self.assertTrue(classes[page])
コード例 #4
0
    def test_is_person_with_accent(self):
        """
        Test checking whether a page that has an accent in it can still be assessed.
        """

        page = 'Jeff Reine-Adélaïde'
        classes = info.is_person(page)
        self.assertEqual(1, len(classes))
        self.assertTrue(all(classes.values()))
コード例 #5
0
    def test_is_person_multiple_pages(self):
        """
        Test checking whether a number of articles are about persons.
        """

        pages = ['Lyon', 'Bordeaux']
        classes = info.is_person(pages)
        self.assertEqual(len(pages), len(classes))
        self.assertFalse(any(classes[page] for page in pages))
コード例 #6
0
    def test_is_person_with_redirects(self):
        """
        Test checking whether an article that redirects still checks that the subject is a person.
        """

        page = 'Messi'
        classes = info.is_person(page)
        self.assertTrue(page in classes)
        self.assertEqual(2, len(classes))
        self.assertTrue(all(classes.values()))
コード例 #7
0
    def postprocess(self, participants, *args, **kwargs):
        """
        Postprocess the given participants.

        :param participants: The participants to postprocess.
                             It is assumed that all map to a Wikipedia page.
        :type participants: list of str

        :return: The postprocessed participants.
        :rtype: list of str
        """

        if self.surname_only:
            """
            If only surnames should be retained for persons, get the participant information.
            If the participant is a person, remove the first component of their name.
            The only exceptions is if the surname is a word, like `Young` in `Ashley Young`.
            In these cases, retain the full name.
            If surnames are to be removed, brackets are also always removed.
            """
            persons = info.is_person(participants)
            for i, participant in enumerate(participants):
                # TODO: Look for "commonly known simply as" (Memphis) or "commonly known as" (Juninho) relations.
                if persons[participant]:
                    participants[i] = self._get_surname(participant)
        """
        Remove the brackets if need be.
        """
        participants = [
            self._remove_brackets(participant) for participant in participants
        ] if self.remove_brackets else participants
        """
        Remove the accents if need be.
        """
        participants = [
            self._remove_accents(participant) for participant in participants
        ] if self.remove_accents else participants

        return participants
コード例 #8
0
    def test_is_person_many_pages(self):
        """
        Test checking whether many pages are about persons.
        """

        pages = [
            'Anthony Lopes', 'Mapou Yanga-Mbiwa',
            'Joachim Andersen (footballer)', 'Rafael (footballer, born 1990)',
            'Jason Denayer', 'Houssem Aouar',
            'Moussa Dembélé (French_footballer)', 'Memphis Depay',
            'Thiago Mendes', 'Léo Dubois', 'Oumar Solet',
            'Jeff Reine-Adélaïde', 'Rayan Cherki', 'Bruno Guimarães',
            'Amine Gouiri', 'Fernando Marçal', 'Karl Toko Ekambi',
            'Kenny Tete', 'Maxence Caqueret', 'Camilo Reijers de Oliveira',
            'Maxwel Cornet', 'Youssouf Koné (footballer, born 1995)',
            'Ciprian Tătărușanu', 'Boubacar Fofana', 'Bertrand Traoré',
            'Martin Terrier', 'Marcelo (footballer, born 1987)',
            'Jean Lucas Oliveira', 'Lucas Tousart'
        ]

        classes = info.is_person(pages)
        self.assertEqual(len(pages), len(classes))
        self.assertTrue(all(classes.values()))
コード例 #9
0
    def test_is_person_no_articles(self):
        """
        Test that when no articles are given, an empty dictionary is returned.
        """

        self.assertFalse(info.is_person([]))