From 30858015e2be98300ce6ecfe18d6ac1651af9915 Mon Sep 17 00:00:00 2001 From: Kaisa Kuivalahti Date: Tue, 3 Sep 2024 15:50:45 +0300 Subject: [PATCH] EKIR-232 Add demarque to classification audience --- core/classifier/__init__.py | 2 -- core/classifier/demarque.py | 2 +- core/model/classification.py | 2 ++ tests/core/classifiers/test_demarque.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/classifier/__init__.py b/core/classifier/__init__.py index 032173efe..8eac439b1 100644 --- a/core/classifier/__init__.py +++ b/core/classifier/__init__.py @@ -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 ( @@ -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. diff --git a/core/classifier/demarque.py b/core/classifier/demarque.py index 823931772..8f43be3ff 100644 --- a/core/classifier/demarque.py +++ b/core/classifier/demarque.py @@ -59,4 +59,4 @@ def target_age(cls, identifier, name): return (17, None) -Classifier.classifiers[Classifier.DEMARQUE] = DeMarqueClassifier \ No newline at end of file +Classifier.classifiers[Classifier.DEMARQUE] = DeMarqueClassifier diff --git a/core/model/classification.py b/core/model/classification.py index 4e94fbe23..2f6e45a9b 100644 --- a/core/model/classification.py +++ b/core/model/classification.py @@ -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] @@ -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() diff --git a/tests/core/classifiers/test_demarque.py b/tests/core/classifiers/test_demarque.py index ec74dcf4f..50305ab52 100644 --- a/tests/core/classifiers/test_demarque.py +++ b/tests/core/classifiers/test_demarque.py @@ -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") \ No newline at end of file + assert (17, None) == DeMarqueClassifier.target_age("READ0005", "Young Adult")