-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from NatLibFi/EKIR-232-demarque-audience-age-m…
…apping Ekir 232 demarque audience age mapping
- Loading branch information
Showing
5 changed files
with
151 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
"""Classifier to extract classifications from De Marque data. | ||
""" | ||
from core.classifier import * | ||
|
||
|
||
class DeMarqueClassifier(Classifier): | ||
@classmethod | ||
def scrub_identifier(cls, identifier): | ||
""" | ||
Make sure that the identifier matches with De Marque codes. | ||
:param identifier: The identifier to be scrubbed. | ||
:return: The scrubbed identifier. | ||
""" | ||
if identifier.startswith("READ"): | ||
return identifier | ||
|
||
@classmethod | ||
def scrub_name(cls, name): | ||
""" | ||
Read in the De Marque name of the subject code. | ||
:param name: The name of the subject. | ||
""" | ||
if name: | ||
return name | ||
|
||
@classmethod | ||
def audience(cls, identifier, name): | ||
""" | ||
Function to determine the audience based on the given identifier. | ||
:param identifier: The identifier to check for audience classification. | ||
:param name: The name associated with the identifier. | ||
:return: The audience classification based on the identifier. | ||
""" | ||
if identifier in ["READ0001", "READ0002", "READ0003"]: | ||
return cls.AUDIENCE_CHILDREN | ||
elif identifier in ["READ0004", "READ0005"]: | ||
return cls.AUDIENCE_YOUNG_ADULT | ||
return cls.AUDIENCE_ADULT | ||
|
||
@classmethod | ||
def target_age(cls, identifier, name): | ||
""" | ||
Function that determines the target age range based on the given identifier. | ||
:param identifier: The identifier to check for target age classification. | ||
:return: A tuple representing the target age range. | ||
""" | ||
if identifier == "READ0001": | ||
return (0, 3) | ||
if identifier == "READ0002": | ||
return (4, 7) | ||
if identifier == "READ0003": | ||
return (8, 12) | ||
if identifier == "READ0004": | ||
return (13, 18) | ||
if identifier == "READ0005": | ||
return (17, None) | ||
|
||
|
||
Classifier.classifiers[Classifier.DEMARQUE] = DeMarqueClassifier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.