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 )
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)
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)
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)
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)
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 )