Skip to content

Commit

Permalink
EKIR-206 Add rules for missing fiction genres
Browse files Browse the repository at this point in the history
  • Loading branch information
natlibfi-kaisa committed Jan 9, 2025
1 parent 87843a5 commit 5ca7c5b
Show file tree
Hide file tree
Showing 2 changed files with 210 additions and 0 deletions.
53 changes: 53 additions & 0 deletions core/classifier/bisac.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ class BISACClassifier(Classifier):
m(Horror, fiction, "Vampires"),
m(Horror, fiction, "Werewolves & Shifters"),
m(Horror, fiction, "Zombies"),
m(Humorous_Fiction, fiction, "Absurdist"),
m(Humorous_Fiction, fiction, "Humorous Stories"),
m(Humorous_Nonfiction, "Young Adult Nonfiction", "Humor"),
m(Law, nonfiction, "Law & Crime"),
Expand Down Expand Up @@ -597,6 +598,58 @@ class BISACClassifier(Classifier):
# well for now.
# For nonfiction, "Social Topics" covers both Juvenile and YA.
m(Life_Strategies, nonfiction, social_topics),
m(General_Fiction, fiction, "Adaptations & Pastiche"),
m(General_Fiction, fiction, "African American & Black"),
m(General_Fiction, fiction, "Amish & Mennonite"),
m(General_Fiction, fiction, "Animals"),
m(General_Fiction, fiction, "Asian American & Pacific Islander"),
m(General_Fiction, fiction, "Biographical"),
m(General_Fiction, fiction, "Buddhist"),
m(Urban_Fiction, fiction, "City Life"),
m(General_Fiction, fiction, "Coming of Age"),
m(Folklore, fiction, "Cultural Heritage"),
m(General_Fiction, fiction, "Disabilities"),
m(General_Fiction, fiction, "Disaster"),
m(General_Fiction, fiction, "Diversity & Multicultural"),
m(General_Fiction, fiction, "Epistolary"),
m(General_Fiction, fiction, "Family Life"),
m(General_Fiction, fiction, "Feminist"),
m(General_Fiction, fiction, "Friendship"),
m(Urban_Fiction, fiction, "Hispanic & Latino", "Urban & Street Lit"),
m(General_Fiction, fiction, "Hispanic & Latino"),
m(General_Fiction, fiction, "Holidays"),
m(General_Fiction, fiction, "Immigration"),
m(Urban_Fiction, fiction, "Indigenous", "City Life"),
m(Science_Fiction, fiction, "Indigenous", "Indigenous Futurism"),
m(Folklore, fiction, "Indigenous", "Oral Storytelling & Teachings"),
m(General_Fiction, fiction, "Indigenous"),
m(General_Fiction, fiction, "Indigenous Peoples of Turtle Island"),
m(General_Fiction, fiction, "Legal"),
m(General_Fiction, fiction, "Mashups"),
m(General_Fiction, fiction, "Media Tie-In"),
m(General_Fiction, fiction, "Medical"),
m(General_Fiction, fiction, "Middle Eastern & Arab American"),
m(General_Fiction, fiction, "Multiple Timelines"),
m(General_Fiction, fiction, "Muslim"),
m(General_Fiction, fiction, "Native American"),
m(General_Fiction, fiction, "Nature & the Environment"),
m(General_Fiction, fiction, "Neurodiversity"),
m(General_Fiction, fiction, "Own Voices"),
m(General_Fiction, fiction, "Performing Arts"),
m(General_Fiction, fiction, "Political"),
m(General_Fiction, fiction, "Psychological"),
m(General_Fiction, fiction, "Small Town & Rural"),
m(General_Fiction, fiction, "Southern"),
m(General_Fiction, fiction, "Sports"),
m(General_Fiction, fiction, "Suburban"),
m(Urban_Fiction, fiction, "Urban & Street Lit"),
m(General_Fiction, fiction, "Women"),
m(Historical_Fiction, fiction, "World Literature", something, "Colonial & Revolutionary Periods"),
m(Historical_Fiction, fiction, "World Literature", something, "Colonial & 19th Century"),
m(Historical_Fiction, fiction, "World Literature", something, "16th & 17th Century"),
m(Historical_Fiction, fiction, "World Literature", something, "18th Century"),
m(Historical_Fiction, fiction, "World Literature", something, "19th Century"),
m(General_Fiction, fiction, "World Literature"),
]

@classmethod
Expand Down
157 changes: 157 additions & 0 deletions tests/core/classifiers/test_bisac.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,161 @@ def test_genre_spot_checks(self):
genre_is("JUVENILE FICTION / Dystopian", "Dystopian SF")
genre_is("JUVENILE FICTION / Stories in Verse (see also Poetry)", "Poetry")

# These tests cover the missing rules for new BISAC codes
genre_is("FICTION / Absurdist", "Humorous Fiction")
genre_is("FICTION / Adaptations & Pastiche", "General Fiction")
genre_is("FICTION / African American & Black / General", "General Fiction")
genre_is("FICTION / African American & Black / Women", "General Fiction")
genre_is("FICTION / Amish & Mennonite", "General Fiction")
genre_is("FICTION / Animals", "General Fiction")
genre_is("FICTION / Asian American & Pacific Islander", "General Fiction")
genre_is("FICTION / Biographical", "General Fiction")
genre_is("FICTION / Buddhist", "General Fiction")
genre_is("FICTION / City Life", "Urban Fiction")
genre_is("FICTION / Coming of Age", "General Fiction")
genre_is("FICTION / Cultural Heritage", "Folklore")
genre_is("FICTION / Disabilities", "General Fiction")
genre_is("FICTION / Disaster", "General Fiction")
genre_is("FICTION / Diversity & Multicultural", "General Fiction")
genre_is("FICTION / Epistolary", "General Fiction")
genre_is("FICTION / Family Life / General", "General Fiction")
genre_is("FICTION / Family Life / Marriage & Divorce", "General Fiction")
genre_is("FICTION / Family Life / Siblings", "General Fiction")
genre_is("FICTION / Feminist", "General Fiction")
genre_is("FICTION / Friendship", "General Fiction")
genre_is("FICTION / Hispanic & Latino / Family Life", "General Fiction")
genre_is("FICTION / Hispanic & Latino / General", "General Fiction")
genre_is("FICTION / Hispanic & Latino / Inspirational", "General Fiction")
genre_is("FICTION / Hispanic & Latino / Urban & Street Lit", "Urban Fiction")
genre_is("FICTION / Hispanic & Latino / Women", "General Fiction")
genre_is("FICTION / Holidays", "General Fiction")
genre_is("FICTION / Immigration", "General Fiction")
genre_is("FICTION / Indigenous / General (see also Indigenous Peoples of Turtle Island or Native American)", "General Fiction")
genre_is("FICTION / Indigenous / City Life", "Urban Fiction")
genre_is("FICTION / Indigenous / Elders", "General Fiction")
genre_is("FICTION / Indigenous / Family Life", "General Fiction")
genre_is("FICTION / Indigenous / Indigenous Futurism", "Science Fiction")
genre_is("FICTION / Indigenous / Life Stories", "General Fiction")
genre_is("FICTION / Indigenous / Oral Storytelling & Teachings", "Folklore")
genre_is("FICTION / Indigenous / Women", "General Fiction")
genre_is("FICTION / Indigenous / Indigenous Peoples of Turtle Island", "General Fiction")
genre_is("FICTION / Legal", "General Fiction")
genre_is("FICTION / Mashups", "General Fiction")
genre_is("FICTION / Media Tie-In", "General Fiction")
genre_is("FICTION / Medical", "General Fiction")
genre_is("FICTION / Middle Eastern & Arab American", "General Fiction")
genre_is("FICTION / Multiple Timelines", "General Fiction")
genre_is("FICTION / Muslim", "General Fiction")
genre_is("FICTION / Native American", "General Fiction")
genre_is("FICTION / Nature & the Environment", "General Fiction")
genre_is("FICTION / Neurodiversity", "General Fiction")
genre_is("FICTION / Own Voices", "General Fiction")
genre_is("FICTION / Performing Arts / General", "General Fiction")
genre_is("FICTION / Performing Arts / Dance, Theater & Musicals", "General Fiction")
genre_is("FICTION / Performing Arts / Film, Television & Radio", "General Fiction")
genre_is("FICTION / Performing Arts / Music", "General Fiction")
genre_is("FICTION / Political", "General Fiction")
genre_is("FICTION / Psychological", "General Fiction")
genre_is("FICTION / Small Town & Rural", "General Fiction")
genre_is("FICTION / Southern", "General Fiction")
genre_is("FICTION / Sports", "General Fiction")
genre_is("FICTION / Suburban", "General Fiction")
genre_is("FICTION / Urban & Street Lit", "Urban Fiction")
genre_is("FICTION / Women", "General Fiction")
genre_is("FICTION / World Literature / Africa / East Africa", "General Fiction")
genre_is("FICTION / World Literature / Africa / General", "General Fiction")
genre_is("FICTION / World Literature / Africa / Nigeria", "General Fiction")
genre_is("FICTION / World Literature / Africa / Southern Africa", "General Fiction")
genre_is("FICTION / World Literature / Africa / West Africa", "General Fiction")
genre_is("FICTION / World Literature / American / 19th Century", "Historical Fiction")
genre_is("FICTION / World Literature / American / 20th Century", "General Fiction")
genre_is("FICTION / World Literature / American / 21st Century", "General Fiction")
genre_is("FICTION / World Literature / American / Colonial & Revolutionary Periods", "Historical Fiction")
genre_is("FICTION / World Literature / American / General", "General Fiction")
genre_is("FICTION / World Literature / Argentina", "General Fiction")
genre_is("FICTION / World Literature / Asia (General)", "General Fiction")
genre_is("FICTION / World Literature / Australia", "General Fiction")
genre_is("FICTION / World Literature / Austria", "General Fiction")
genre_is("FICTION / World Literature / Brazil", "General Fiction")
genre_is("FICTION / World Literature / Canada / 20th Century", "General Fiction")
genre_is("FICTION / World Literature / Canada / 21st Century", "General Fiction")
genre_is("FICTION / World Literature / Canada / Colonial & 19th Century", "Historical Fiction")
genre_is("FICTION / World Literature / Canada / General", "General Fiction")
genre_is("FICTION / World Literature / Caribbean & West Indies", "General Fiction")
genre_is("FICTION / World Literature / Central America", "General Fiction")
genre_is("FICTION / World Literature / Central Asia", "General Fiction")
genre_is("FICTION / World Literature / Chile", "General Fiction")
genre_is("FICTION / World Literature / China / 19th Century", "Historical Fiction")
genre_is("FICTION / World Literature / China / 20th Century", "General Fiction")
genre_is("FICTION / World Literature / China / 21st Century", "General Fiction")
genre_is("FICTION / World Literature / China / General", "General Fiction")
genre_is("FICTION / World Literature / Colombia", "General Fiction")
genre_is("FICTION / World Literature / Czech Republic", "General Fiction")
genre_is("FICTION / World Literature / Denmark", "General Fiction")
genre_is("FICTION / World Literature / England / 16th & 17th Century", "Historical Fiction")
genre_is("FICTION / World Literature / England / 18th Century", "Historical Fiction")
genre_is("FICTION / World Literature / England / 19th Century", "Historical Fiction")
genre_is("FICTION / World Literature / England / 20th Century", "General Fiction")
genre_is("FICTION / World Literature / England / 21st Century", "General Fiction")
genre_is("FICTION / World Literature / England / Early & Medieval Periods", "General Fiction")
genre_is("FICTION / World Literature / England / General", "General Fiction")
genre_is("FICTION / World Literature / Europe (General)", "General Fiction")
genre_is("FICTION / World Literature / Finland", "General Fiction")
genre_is("FICTION / World Literature / France / 18th Century", "Historical Fiction")
genre_is("FICTION / World Literature / France / 19th Century", "Historical Fiction")
genre_is("FICTION / World Literature / France / 20th Century", "General Fiction")
genre_is("FICTION / World Literature / France / 21st Century", "General Fiction")
genre_is("FICTION / World Literature / France / General", "General Fiction")
genre_is("FICTION / World Literature / Germany / 20th Century", "General Fiction")
genre_is("FICTION / World Literature / Germany / 21st Century", "General Fiction")
genre_is("FICTION / World Literature / Germany / General", "General Fiction")
genre_is("FICTION / World Literature / Greece", "General Fiction")
genre_is("FICTION / World Literature / Hungary", "General Fiction")
genre_is("FICTION / World Literature / India / 19th Century", "Historical Fiction")
genre_is("FICTION / World Literature / India / 20th Century", "General Fiction")
genre_is("FICTION / World Literature / India / 21st Century", "General Fiction")
genre_is("FICTION / World Literature / India / General", "General Fiction")
genre_is("FICTION / World Literature / Ireland / 19th Century", "Historical Fiction")
genre_is("FICTION / World Literature / Ireland / 20th Century", "General Fiction")
genre_is("FICTION / World Literature / Ireland / 21st Century", "General Fiction")
genre_is("FICTION / World Literature / Ireland / General", "General Fiction")
genre_is("FICTION / World Literature / Italy", "General Fiction")
genre_is("FICTION / World Literature / Japan", "General Fiction")
genre_is("FICTION / World Literature / Korea", "General Fiction")
genre_is("FICTION / World Literature / Mexico", "General Fiction")
genre_is("FICTION / World Literature / Middle East / Arabian Peninsula", "General Fiction")
genre_is("FICTION / World Literature / Middle East / Egypt & North Africa", "General Fiction")
genre_is("FICTION / World Literature / Middle East / General", "General Fiction")
genre_is("FICTION / World Literature / Middle East / Israel", "General Fiction")
genre_is("FICTION / World Literature / Netherlands", "General Fiction")
genre_is("FICTION / World Literature / New Zealand", "General Fiction")
genre_is("FICTION / World Literature / Norway", "General Fiction")
genre_is("FICTION / World Literature / Oceania", "General Fiction")
genre_is("FICTION / World Literature / Pakistan", "General Fiction")
genre_is("FICTION / World Literature / Peru", "General Fiction")
genre_is("FICTION / World Literature / Poland", "General Fiction")
genre_is("FICTION / World Literature / Portugal", "General Fiction")
genre_is("FICTION / World Literature / Russia / 19th Century", "Historical Fiction")
genre_is("FICTION / World Literature / Russia / 20th Century", "General Fiction")
genre_is("FICTION / World Literature / Russia / 21st Century", "General Fiction")
genre_is("FICTION / World Literature / Russia / General", "General Fiction")
genre_is("FICTION / World Literature / Scotland / 19th Century", "Historical Fiction")
genre_is("FICTION / World Literature / Scotland / 20th Century", "General Fiction")
genre_is("FICTION / World Literature / Scotland / 21st Century", "General Fiction")
genre_is("FICTION / World Literature / Scotland / General", "General Fiction")
genre_is("FICTION / World Literature / South America (General)", "General Fiction")
genre_is("FICTION / World Literature / Southeast Asia", "General Fiction")
genre_is("FICTION / World Literature / Spain / 19th Century", "Historical Fiction")
genre_is("FICTION / World Literature / Spain / 20th Century", "General Fiction")
genre_is("FICTION / World Literature / Spain / 21st Century", "General Fiction")
genre_is("FICTION / World Literature / Spain / General", "General Fiction")
genre_is("FICTION / World Literature / Sweden", "General Fiction")
genre_is("FICTION / World Literature / Switzerland", "General Fiction")
genre_is("FICTION / World Literature / Turkey", "General Fiction")
genre_is("FICTION / World Literature / Uruguay", "General Fiction")
genre_is("FICTION / World Literature / Wales", "General Fiction")


def test_deprecated_bisac_terms(self):
"""These BISAC terms have been deprecated. We classify them
the same as the new terms.
Expand Down Expand Up @@ -308,6 +463,8 @@ def fiction_is(name, expect):
fiction_is("YOUNG ADULT FICTION / Lifestyles / Country Life", True)
fiction_is("HISTORY / General", False)

fiction_is("JUVENILE FICTION / General", True)

def test_audience_spot_checks(self):
def audience_is(name, expect):
subject = self._subject("", name)
Expand Down

0 comments on commit 5ca7c5b

Please sign in to comment.