Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better use of call numbers for similar items #4119

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 50 additions & 17 deletions import/index_java/src/org/vufind/index/CallNumberTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
Expand All @@ -40,34 +41,66 @@
public class CallNumberTools
{
/**
* Extract the call number label from a record
* Extract the call number labels from a record
* @param record MARC record
* @return Call number label
* @return Call number labels
*/
public String getCallNumberLabel(final Record record) {
public List<String> getCallNumberLabel(final Record record) {

return getCallNumberLabel(record, "090a:050a");
return getCallNumberLabel(record, "050a:082a:083a:090a");
}

/**
* Extract the call number label from a record
* Extract the call number labels from a record.
* fieldSpec might include 952e for FOLIO, in which case we do not know the type of call number
* (also sometimes call numbers are in the wrong MARC field for their type).
* If LCC: classLetters, classLetters + classDigits, classLetters + classDigits + classDecimal
* If Dewey: classDigits, classDigits + classDecimal
* Otherwise: everything up until the dot (or everything if there is no dot)
* @param record MARC record
* @param fieldSpec taglist for call number fields
* @return Call number label
* @return Call number labels
*/
public String getCallNumberLabel(final Record record, String fieldSpec) {

String val = SolrIndexer.instance().getFirstFieldVal(record, fieldSpec);

if (val != null) {
int dotPos = val.indexOf(".");
if (dotPos > 0) {
val = val.substring(0, dotPos);
public List<String> getCallNumberLabel(final Record record, String fieldSpec) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For backward-compatibility, how about renaming this method to getCallNumberLabels, and then keeping a getCallNumberLabel method that returns the first value from getCallNumberLabels?

Set<String> values = SolrIndexer.instance().getFieldList(record, fieldSpec);
HashSet<String> result = new LinkedHashSet<String>();
for (String cn: values) {
String cnUp = cn.toUpperCase().trim();
LCCallNumber lcc = new LCCallNumber(cnUp);
DeweyCallNumber dewey = new DeweyCallNumber(cnUp);
boolean other = cnUp.contains(":") || (cnUp.length() > 10 && !cnUp.contains("."));
boolean isLcc = lcc.isValid() && !other;
boolean isDewey = dewey.isValid() && !other;
if (isLcc) {
result.add(lcc.getClassLetters());
result.add(lcc.getClassLetters() + lcc.getClassDigits());
if (lcc.getClassDecimal() != null) {
result.add(lcc.getClassLetters() + lcc.getClassDigits() + lcc.getClassDecimal());
}
} else if (isDewey) {
result.add(dewey.getClassDigits());
String classDecimal = dewey.getClassDecimal();
if (classDecimal != null) {
for (int i=1; i<5; i++) {
if (classDecimal.length() > i) {
result.add(dewey.getClassDigits() + classDecimal.substring(0, i+1));
}
}
}
} else {
// NOTE: we could add other classifications like SuDoc here (and add related MARC fields to fieldSpec)
int dotPos = cnUp.indexOf(".");
if (dotPos < 0) {
result.add(cnUp.trim());
continue;
}
if (dotPos == 0) {
continue;
}
result.add(cnUp.substring(0, dotPos).trim());
}
return val.toUpperCase();
} else {
return val;
}
return new ArrayList<String>(result);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion import/marc.properties
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ issn = 022a:440x:490x:730x:773x:776x:780x:785x

callnumber-first = 099a[0]:090a[0]:050a[0], callnumber_map.properties, first
callnumber-subject = custom, getCallNumberSubject(090a:050a), callnumber_subject_map.properties
callnumber-label = custom, getCallNumberLabel(090a:050a)
callnumber-label = custom, getCallNumberLabel(050a:082a:083a:090a)
callnumber-sort = custom, getLCSortable(099ab:090ab:050ab)
callnumber-raw = 099ab:090ab:050ab

Expand Down
2 changes: 1 addition & 1 deletion module/VuFind/tests/fixtures/misc/testbug2.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"callnumber-subject-code":"DG",
"spelling":"Vico, Giambattista, 1668-1744. Principum Neapolitanorum coniurationis anni MDCCI historia. Italian & Latin La congiura dei Principi Napoletani 1701 : (prima e seconda stesura) / Giambattista Vico ; a cura di Claudia Pandolfi. Fictional edition. Morano : Centro di Studi Vichiani, 1992. 296 p. : ill. ; 24 cm. Opere di Giambattista Vico ; 2/1 Italian and Latin. Includes bibliographical references (p. [277]-281) and index. Sample abstract. April11phi Naples (Kingdom) History Spanish rule, 1442-1707 Sources. Pandolfi, Claudia. Vico, Giambattista, 1668-1744. Works. 1982 ; 2, pt. 1. http://fictional.com/sample/url",
"title_sub":"(prima e seconda stesura) /",
"callnumber-label":"DG848",
"callnumber-label":["DG848"],
"record_format":"marc",
"callnumber-first":"D - World History",
"title_auth":"La congiura dei Principi Napoletani 1701 : (prima e seconda stesura) /",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"isbn":["1558612742 (pbk. : alk. paper)"],
"callnumber-first":"P - Language and Literature",
"callnumber-subject":"PS - American Literature",
"callnumber-label":"PS3552",
"callnumber-label":["PS3552"],
"callnumber-sort":"PS 43552 R878 T47 42001",
"callnumber-raw":["PS3552.R878 T47 2001"],
"callnumber-search":["PS3552.R878 T47 2001"],
Expand Down Expand Up @@ -157,7 +157,7 @@
"isbn":["1558612742 (pbk. : alk. paper)"],
"callnumber-first":"P - Language and Literature",
"callnumber-subject":"PS - American Literature",
"callnumber-label":"PS3552",
"callnumber-label":["PS3552"],
"callnumber-sort":"PS 43552 R878 T47 42021",
"callnumber-raw":["PS3552.R878 T47 2021"],
"callnumber-search":["PS3552.R878 T47 2021"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"isbn":["1558612742 (pbk. : alk. paper)"],
"callnumber-first":"P - Language and Literature",
"callnumber-subject":"PS - American Literature",
"callnumber-label":"PS3552",
"callnumber-label":["PS3552"],
"callnumber-sort":"PS 43552 R878 T47 42001",
"callnumber-raw":["PS3552.R878 T47 2001"],
"callnumber-search":["PS3552.R878 T47 2001"],
Expand Down Expand Up @@ -157,7 +157,7 @@
"isbn":["1558612742 (pbk. : alk. paper)"],
"callnumber-first":"P - Language and Literature",
"callnumber-subject":"PS - American Literature",
"callnumber-label":"PS3552",
"callnumber-label":["PS3552"],
"callnumber-sort":"PS 43552 R878 T47 42021",
"callnumber-raw":["PS3552.R878 T47 2021"],
"callnumber-search":["PS3552.R878 T47 2021"],
Expand Down Expand Up @@ -233,7 +233,7 @@
"isbn":["1558612742 (pbk. : alk. paper)"],
"callnumber-first":"P - Language and Literature",
"callnumber-subject":"PS - American Literature",
"callnumber-label":"PS3552",
"callnumber-label":["PS3552"],
"callnumber-sort":"PS 43552 R878 T47 42011",
"callnumber-raw":["PS3552.R878 T47 2011"],
"callnumber-search":["PS3552.R878 T47 2011"],
Expand Down Expand Up @@ -309,7 +309,7 @@
"isbn":["1558612742 (pbk. : alk. paper)"],
"callnumber-first":"P - Language and Literature",
"callnumber-subject":"PS - American Literature",
"callnumber-label":"PS3552",
"callnumber-label":["PS3552"],
"callnumber-sort":"PS 43552 R878 T47 42011",
"callnumber-raw":["PS3552.R878 T47 2011"],
"callnumber-search":["PS3552.R878 T47 2011"],
Expand Down Expand Up @@ -385,7 +385,7 @@
"isbn":["1558612742 (pbk. : alk. paper)"],
"callnumber-first":"P - Language and Literature",
"callnumber-subject":"PS - American Literature",
"callnumber-label":"PS3552",
"callnumber-label":["PS3552"],
"callnumber-sort":"PS 43552 R878 T47 42011",
"callnumber-raw":["PS3552.R878 T47 2011"],
"callnumber-search":["PS3552.R878 T47 2011"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"isbn":["1558612742 (pbk. : alk. paper)"],
"callnumber-first":"P - Language and Literature",
"callnumber-subject":"PS - American Literature",
"callnumber-label":"PS3552",
"callnumber-label":["PS3552"],
"callnumber-sort":"PS 43552 R878 T47 42001",
"callnumber-raw":["PS3552.R878 T47 2001"],
"callnumber-search":["PS3552.R878 T47 2001"],
Expand Down Expand Up @@ -157,7 +157,7 @@
"isbn":["1558612742 (pbk. : alk. paper)"],
"callnumber-first":"P - Language and Literature",
"callnumber-subject":"PS - American Literature",
"callnumber-label":"PS3552",
"callnumber-label":["PS3552"],
"callnumber-sort":"PS 43552 R878 T47 42021",
"callnumber-raw":["PS3552.R878 T47 2021"],
"callnumber-search":["PS3552.R878 T47 2021"],
Expand Down Expand Up @@ -233,7 +233,7 @@
"isbn":["1558612742 (pbk. : alk. paper)"],
"callnumber-first":"P - Language and Literature",
"callnumber-subject":"PS - American Literature",
"callnumber-label":"PS3552",
"callnumber-label":["PS3552"],
"callnumber-sort":"PS 43552 R878 T47 42011",
"callnumber-raw":["PS3552.R878 T47 2011"],
"callnumber-search":["PS3552.R878 T47 2011"],
Expand Down Expand Up @@ -309,7 +309,7 @@
"isbn":["1558612742 (pbk. : alk. paper)"],
"callnumber-first":"P - Language and Literature",
"callnumber-subject":"PS - American Literature",
"callnumber-label":"PS3552",
"callnumber-label":["PS3552"],
"callnumber-sort":"PS 43552 R878 T47 42011",
"callnumber-raw":["PS3552.R878 T47 2011"],
"callnumber-search":["PS3552.R878 T47 2011"],
Expand Down Expand Up @@ -385,7 +385,7 @@
"isbn":["1558612742 (pbk. : alk. paper)"],
"callnumber-first":"P - Language and Literature",
"callnumber-subject":"PS - American Literature",
"callnumber-label":"PS3552",
"callnumber-label":["PS3552"],
"callnumber-sort":"PS 43552 R878 T47 42011",
"callnumber-raw":["PS3552.R878 T47 2011"],
"callnumber-search":["PS3552.R878 T47 2011"],
Expand Down Expand Up @@ -461,7 +461,7 @@
"isbn":["1558612742 (pbk. : alk. paper)"],
"callnumber-first":"P - Language and Literature",
"callnumber-subject":"PS - American Literature",
"callnumber-label":"PS3552",
"callnumber-label":["PS3552"],
"callnumber-sort":"PS 43552 R878 T47 42011",
"callnumber-raw":["PS3552.R878 T47 2011"],
"callnumber-search":["PS3552.R878 T47 2011"],
Expand Down Expand Up @@ -537,7 +537,7 @@
"isbn":["1558612742 (pbk. : alk. paper)"],
"callnumber-first":"P - Language and Literature",
"callnumber-subject":"PS - American Literature",
"callnumber-label":"PS3552",
"callnumber-label":["PS3552"],
"callnumber-sort":"PS 43552 R878 T47 42011",
"callnumber-raw":["PS3552.R878 T47 2011"],
"callnumber-search":["PS3552.R878 T47 2011"],
Expand Down Expand Up @@ -608,7 +608,7 @@
"isbn":["8820737493"],
"callnumber-first":"D - World History",
"callnumber-subject":"DG - Italy, Malta",
"callnumber-label":"DG848",
"callnumber-label":["DG848"],
"callnumber-sort":"DG 3848.15 V53 41992",
"callnumber-raw":["DG848.15 .V53 1992"],
"callnumber-search":["DG848.15 .V53 1992"],
Expand Down Expand Up @@ -661,7 +661,7 @@
"isbn":["8820737493"],
"callnumber-first":"D - World History",
"callnumber-subject":"DG - Italy, Malta",
"callnumber-label":"DG848",
"callnumber-label":["DG848"],
"callnumber-sort":"DG 3848.15 V53 41992",
"callnumber-raw":["DG848.15 .V53 1992"],
"callnumber-search":["DG848.15 .V53 1992"],
Expand Down

Large diffs are not rendered by default.

Loading