Exemplo n.º 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
     )
Exemplo n.º 2
0
 def audience(cls, identifier, name):
     for ruleset in cls.AUDIENCE:
         audience = ruleset.match(*name)
         if audience is cls.stop:
             return None
         if audience is not None:
             return audience
     keyword = "/".join(name)
     return KeywordBasedClassifier.audience(identifier, keyword)
Exemplo n.º 3
0
 def is_fiction(cls, identifier, name):
     for ruleset in cls.FICTION:
         fiction = ruleset.match(*name)
         if fiction is cls.stop:
             return None
         if fiction is not None:
             return fiction
     keyword = "/".join(name)
     return KeywordBasedClassifier.is_fiction(identifier, keyword)
Exemplo n.º 4
0
 def audience(cls, identifier, name):
     for ruleset in cls.AUDIENCE:
         audience = ruleset.match(*name)
         if audience is cls.stop:
             return None
         if audience is not None:
             return audience
     keyword = "/".join(name)
     return KeywordBasedClassifier.audience(identifier, keyword)
Exemplo n.º 5
0
 def is_fiction(cls, identifier, name):
     for ruleset in cls.FICTION:
         fiction = ruleset.match(*name)
         if fiction is cls.stop:
             return None
         if fiction is not None:
             return fiction
     keyword = "/".join(name)
     return KeywordBasedClassifier.is_fiction(identifier, keyword)
Exemplo n.º 6
0
    def target_age(cls, identifier, name):
        for ruleset in cls.TARGET_AGE:
            target_age = ruleset.match(*name)
            if target_age is cls.stop:
                return None
            if target_age is not None:
                return target_age

        # If all else fails, try the keyword-based classifier.
        keyword = "/".join(name)
        return KeywordBasedClassifier.target_age(identifier, keyword)
Exemplo n.º 7
0
    def target_age(cls, identifier, name):
        for ruleset in cls.TARGET_AGE:
            target_age = ruleset.match(*name)
            if target_age is cls.stop:
                return None
            if target_age is not None:
                return target_age

        # If all else fails, try the keyword-based classifier.
        keyword = "/".join(name)
        return KeywordBasedClassifier.target_age(identifier, keyword)
Exemplo n.º 8
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)
Exemplo n.º 9
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
        )