示例#1
0
 def genre(cls, identifier, name, fiction=None, audience=None, **kwargs):
     if fiction and identifier in cls.fiction_genres:
         return cls.fiction_genres[identifier]
     if identifier in cls.genres:
         return cls.genres[identifier]
     return KeywordBasedClassifier.genre(
         identifier, name, fiction, audience, **kwargs
     )
示例#2
0
    def genre(cls, identifier, name, fiction, audience):
        for ruleset in cls.GENRE:
            genre = ruleset.match(*name)
            if genre is cls.stop:
                return None
            if genre is not None:
                return genre

        # If all else fails, try a keyword-based classifier.
        keyword = "/".join(name)
        return KeywordBasedClassifier.genre(identifier, keyword, fiction,
                                            audience)
示例#3
0
    def genre(cls, identifier, name, fiction, audience):
        for ruleset in cls.GENRE:
            genre = ruleset.match(*name)
            if genre is cls.stop:
                return None
            if genre is not None:
                return genre

        # If all else fails, try a keyword-based classifier.
        keyword = "/".join(name)
        return KeywordBasedClassifier.genre(
            identifier, keyword, fiction, audience
        )