internetarchive / internetarchive/openlibrary
Method to convert LCCs to LCC class names
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 138
Description
LCCs can be displayed as a ~path down the classification tree. These provide useful information which we want to display to the user. In order to do that, we need to be able to decode the LCC into classes. (This issue split off from #3290)
### Describe the problem that you'd like solved
Want to be able to programmatically get the data on the right:
| Sample LCC from a real book | Expected Result |
| -- | -- |
| [F1047 .C95](https://openlibrary.org/books/OL13446985M/Prince_Edward_Island_garden_province_of_Canada) | \[
("History of the Americas", ([F](https://dev.openlibrary.org/search?q=lcc%3AF*&mode=everything))),
("British American (including Canada)", [(F1001, F1145.2)](https://dev.openlibrary.org/search?q=lcc%3A%5BF1001+TO+F1145.2%5D&mode=everything)),
("British America", [(F1001, F1145.2)](https://dev.openlibrary.org/search?q=lcc%3A%5BF1001+TO+F1145.2%5D&mode=everything)),
("Canada", [(F1001, F1145.2)](https://dev.openlibrary.org/search?q=lcc%3A%5BF1001+TO+F1145.2%5D&mode=everything)),
("Maritime Provinces", [(F1035.8)](https://dev.openlibrary.org/search?q=lcc%3AF1035.8*&mode=everything)),
("Prince Edward Island", [(F1046, F1049.7)](https://dev.openlibrary.org/search?q=lcc%3A%5BF1046+TO+F1049.7%5D&mode=everything)),
\] |
| [NC760 .B2813 2004](https://openlibrary.org/books/OL3307263M/The_artist's_guide_to_human_anatomy) | \[
("Visual Arts", [(N)](https://dev.openlibrary.org/search?q=lcc%3AN*&mode=everything)),
("Drawing. Design. Illustration", [(NC)](https://dev.openlibrary.org/search?q=lcc%3ANC*&mode=everything)),
("Special subjects", [(NC760, NC825)](https://dev.openlibrary.org/search?q=lcc%3A%5BNC760+TO+NC825%5D&mode=everything)),
\] |
| [QH81 .C3525 1996](https://openlibrary.org/books/OL967995M/Bringing_the_mountain_home) | \[
("Science", [(Q)](https://dev.openlibrary.org/search?q=lcc%3AQ*&mode=everything)),
("Natural History - Biology", [(QH)](https://dev.openlibrary.org/search?q=lcc%3AQH*&mode=everything)),
("Natural History (General)", [(QH1, QH278.5)](https://dev.openlibrary.org/search?q=lcc%3A%5BQH1+TO+QH278.5%5D&mode=everything)),
\] |
| [RF290 .E73 2009](https://openlibrary.org/books/OL22849639M/Essentials_of_audiology) | \[
("Medicine", [(R)](https://dev.openlibrary.org/search?q=lcc%3AR*&mode=everything)),
("Otorhinolaryngology", [(RF)](https://dev.openlibrary.org/search?q=lcc%3ARF*&mode=everything)),
("Otology. Diseases of the ear", [(RF110, RF320)](https://dev.openlibrary.org/search?q=lcc%3A%5BRF110+TO+RF320%5D&mode=everything)),
\] |
| [NB699.N4 B4 1969b](https://openlibrary.org/books/OL5720391M/Art_and_revolution) | \[
("Visual Arts", [(N)](https://dev.openlibrary.org/search?q=lcc%3AN*&mode=everything)),
("Sculpture", [(NB)](https://dev.openlibrary.org/search?q=lcc%3ANB*&mode=everything)),
("History", [(NB60, NB1115)](https://dev.openlibrary.org/search?q=lcc%3A%5BNB60+TO+NB1115%5D&mode=everything)),
\] |
See https://github.com/internetarchive/openlibrary/issues/3290 for more examples; not the table there is missing the first LCC class.
### Proposal & Constraints
- [ ] Needs function that given a string, human-entered LCC from Open Library, returns a list of LCC classes
- [ ] Each class should also include either a range of LCCs or a LCC prefix (see examples above)
Notes:
- For this stage, although LCCs provide information beyond the first digit (e.g. NB699.A14), this feature will be considered complete once classes are given for the LCC up to, but not including, the first cutter number (i.e. not including "A14" in "NB699.A14"). This are expansions we can do in future issues.
- Optional expansion (not required to close this issue; can be done in a future issue): should pass the LCC class names through i18n.
- The examples above are generated using https://www.loc.gov/catdir/cpso/lcco/ . The result doesn't have to be _identical_ to the above, but it should be very similar.
### Additional context
- LCC breakdown: https://www.loc.gov/catdir/cpso/lcco/
- Crash course LCCs: https://github.com/internetarchive/openlibrary/blob/master/openlibrary/utils/lcc.py
- In depth breakdown of LCCs: https://www.terkko.helsinki.fi/files/9666/classify_trnee_manual.pdf
### Stakeholders
@cclauss @BrittanyBunk
Contributor guide
Research direction
Start with openlibrary/utils/lcc.py and review the Library of Congress LCC breakdown linked in the issue. Define the function's input and output around the listed examples, stopping before the first cutter number. Done means human-entered LCC strings return ordered classes with either prefixes or ranges and results similar to the examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100