Skip to content

Commit

Permalink
EKIR-232 Add demarque to classification audience
Browse files Browse the repository at this point in the history
  • Loading branch information
natlibfi-kaisa committed Sep 3, 2024
1 parent 87f266b commit 3085801
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 0 additions & 2 deletions core/classifier/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,6 @@ def add(self, classification):
# "Juvenile Fiction".
self.overdrive_juvenile_generic = classification


# E-kirjasto: Since De Marque classifications have target ages for children's and YA books, we want to weigh
# them more heavily by setting their weights to 1.0. This ensures that those books are classified accordingly.
if subject.type == "De Marque" and (
Expand All @@ -1256,7 +1255,6 @@ def add(self, classification):
):
self.audience_weights = Counter()
self.audience_weights[subject.audience] += weight * 1.0


def weigh_metadata(self):
"""Modify the weights according to the given Work's metadata.
Expand Down
2 changes: 1 addition & 1 deletion core/classifier/demarque.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ def target_age(cls, identifier, name):
return (17, None)


Classifier.classifiers[Classifier.DEMARQUE] = DeMarqueClassifier
Classifier.classifiers[Classifier.DEMARQUE] = DeMarqueClassifier
2 changes: 2 additions & 0 deletions core/model/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Subject(Base):
TAG: str = Classifier.TAG # Folksonomic tags.
FREEFORM_AUDIENCE: str = Classifier.FREEFORM_AUDIENCE
NYPL_APPEAL = Classifier.NYPL_APPEAL
DEMARQUE = Classifier.DEMARQUE

# Types with terms that are suitable for search.
TYPES_FOR_SEARCH = [FAST, OVERDRIVE, BISAC, TAG]
Expand Down Expand Up @@ -92,6 +93,7 @@ class Subject(Base):
"http://www.bisg.org/standards/bisac_subject/": BISAC,
# Feedbooks uses a modified BISAC which we know how to handle.
"http://www.feedbooks.com/categories": BISAC,
"http://schema.org/Audience": DEMARQUE,
}

uri_lookup = dict()
Expand Down
2 changes: 1 addition & 1 deletion tests/core/classifiers/test_demarque.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ def test_target_age(self):
assert (4, 7) == DeMarqueClassifier.target_age("READ0002", "Beginner reader")
assert (8, 12) == DeMarqueClassifier.target_age("READ0003", "Advanced reader")
assert (13, 18) == DeMarqueClassifier.target_age("READ0004", "Teen")
assert (17, None) == DeMarqueClassifier.target_age("READ0005", "Young Adult")
assert (17, None) == DeMarqueClassifier.target_age("READ0005", "Young Adult")

0 comments on commit 3085801

Please sign in to comment.