Esempio n. 1
0
    def test_audience_match(self):
        (audience, match) = Keyword.audience_match("teen books")
        assert Classifier.AUDIENCE_YOUNG_ADULT == audience
        assert "teen books" == match

        # This is a search for a specific example so it doesn't match
        (audience, match) = Keyword.audience_match("teen romance")
        assert None == audience
Esempio n. 2
0
    def test_genre_match(self):
        (genre, match) = Keyword.genre_match("pets")
        assert classifier.Pets == genre
        assert "pets" == match

        # This is a search for a specific example so it doesn't match
        (genre, match) = Keyword.genre_match("cats")
        assert None == genre
Esempio n. 3
0
    def test_juvenile_romance_means_young_adult(self):
        assert Classifier.AUDIENCE_YOUNG_ADULT == Keyword.audience(
            None, "juvenile fiction / love & romance")

        assert Classifier.AUDIENCE_YOUNG_ADULT == Keyword.audience(
            None, "teenage romance")
Esempio n. 4
0
 def test_young_adult_wins_over_children(self):
     assert Classifier.AUDIENCE_YOUNG_ADULT == Keyword.audience(
         None, "children's books - young adult fiction")
Esempio n. 5
0
    def test_audience(self):
        assert Classifier.AUDIENCE_YOUNG_ADULT == Keyword.audience(
            None, "Teens / Fiction")

        assert Classifier.AUDIENCE_YOUNG_ADULT == Keyword.audience(
            None, "teen books")
Esempio n. 6
0
 def genre(self, keyword):
     scrub = Keyword.scrub_identifier(keyword)
     fiction = Keyword.is_fiction(None, scrub)
     audience = Keyword.audience(None, scrub)
     return Keyword.genre(None, scrub, fiction, audience)
Esempio n. 7
0
    def test_improvements(self):
        """A place to put tests for miscellaneous improvements added
        since the original work.
        """
        # was Literary Fiction
        assert classifier.Science_Fiction == Keyword.genre(
            None, "Science Fiction - General")

        # Was General Fiction (!)
        assert classifier.Science_Fiction == Keyword.genre(
            None, "Science Fiction")

        assert classifier.Science_Fiction == Keyword.genre(
            None, "Speculative Fiction")

        assert classifier.Social_Sciences == Keyword.genre(
            None, "Social Sciences")

        assert classifier.Social_Sciences == Keyword.genre(
            None, "Social Science")

        assert classifier.Social_Sciences == Keyword.genre(
            None, "Human Science")

        # was genreless
        assert classifier.Short_Stories == Keyword.genre(None, "Short Stories")

        # was Military History
        assert classifier.Military_SF == Keyword.genre(None,
                                                       "Interstellar Warfare")

        # was Fantasy
        assert classifier.Games == Keyword.genre(
            None, "Games / Role Playing & Fantasy")

        # This isn't perfect but it covers most cases.
        assert classifier.Media_Tie_in_SF == Keyword.genre(
            None, "TV, Movie, Video game adaptations")

        # Previously only 'nonfiction' was recognized.
        assert False == Keyword.is_fiction(None, "Non-Fiction")
        assert False == Keyword.is_fiction(None, "Non Fiction")

        # "Historical" on its own means historical fiction, but a
        # string containing "Historical" does not mean anything in
        # particular.
        assert classifier.Historical_Fiction == Keyword.genre(
            None, "Historical")
        assert None == Keyword.genre(None, "Historicals")

        # The Fiction/Urban classification is different from the
        # African-American-focused "Urban Fiction" classification.
        assert None == Keyword.genre(None, "Fiction/Urban")

        assert classifier.Folklore == Keyword.genre(None, "fables")