Skip to content

Commit

Permalink
PICA: Extend classification/subject headings schemes from config file #…
Browse files Browse the repository at this point in the history
  • Loading branch information
pkiraly committed Nov 7, 2023
1 parent fb36749 commit ea9e2a5
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class ClassificationAnalyzer {
ClassificationSchemes.getInstance();
private static final Pattern NUMERIC = Pattern.compile("^\\d");
public static final String DEWEY_DECIMAL_CLASSIFICATION = "Dewey Decimal Classification";
private static PicaVocabularyManager manager = null;
private static PicaVocabularyManager picaVocabularyManager = null;

private final ClassificationStatistics statistics;
private ClassificationParameters parameters = null;
Expand Down Expand Up @@ -130,8 +130,8 @@ public class ClassificationAnalyzer {
public ClassificationAnalyzer(BibliographicRecord marcRecord, ClassificationStatistics statistics) {
this.marcRecord = marcRecord;
this.statistics = statistics;
if (marcRecord.getSchemaType().equals(SchemaType.PICA) && manager == null) {
manager = PicaVocabularyManager.getInstance();
if (marcRecord.getSchemaType().equals(SchemaType.PICA) && picaVocabularyManager == null) {
picaVocabularyManager = PicaVocabularyManager.getInstance();
}
}

Expand Down Expand Up @@ -182,24 +182,29 @@ private int processFieldsWithScheme(int total, List<FieldWithScheme> fieldsWithS

private int processFieldsWithSchemePica(int total, List<FieldWithScheme> fieldsWithScheme) {
int count = total;
// for (VocabularyEntry entry : manager.getAll()) {
for (FieldWithScheme entry : fieldsWithScheme) {
/*
String tag = entry.getPica();
String schema = entry.getLabel();
String voc = entry.getVoc();
*/
String tag = entry.getTag();
String schema = entry.getSchemaName();
String voc = tag;
try {
voc = classificationSchemes.resolve(schema);
} catch (IllegalArgumentException e) {

boolean processFromTSV = true;
if (processFromTSV) {
for (FieldWithScheme entry : fieldsWithScheme) {
String tag = entry.getTag();
String schema = entry.getSchemaName();
String voc = tag;
try {
voc = classificationSchemes.resolve(schema);
} catch (IllegalArgumentException e) {
}
count += processPicaSubject(tag, voc, schema);
}
if (!marcRecord.hasDatafield(tag))
continue;
} else {
for (VocabularyEntry entry : picaVocabularyManager.getAll()) {
count += processPicaSubject(entry.getPica(), entry.getVoc(), entry.getLabel());
}
}
return count;
}

private int processPicaSubject(String tag, String voc, String schema) {
int count = 0;
if (marcRecord.hasDatafield(tag)) {
List<DataField> fields = marcRecord.getDatafield(tag);
List<Schema> schemas = new ArrayList<>();
for (DataField field : fields) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,15 @@ private static void initializeAuthorityTags() {
subjectTagIndex = Utils.listToMap(subjectTags);
skippableSubjectSubfields = new HashMap<>();
skippableSubjectSubfields.put("022A", Utils.listToMap(Arrays.asList("9", "V", "7", "3", "w")));
skippableSubjectSubfields.put("044H", Utils.listToMap(Arrays.asList("A"))); // A = Quelle
skippableSubjectSubfields.put("044S", Utils.listToMap(Arrays.asList("9", "A", "V", "7", "3", "w")));
skippableSubjectSubfields.put("045F", Utils.listToMap(Arrays.asList("A")));
skippableSubjectSubfields.put("045G", Utils.listToMap(Arrays.asList("A")));
skippableSubjectSubfields.put("045X", Utils.listToMap(Arrays.asList("A")));
skippableSubjectSubfields.put("045Y", Utils.listToMap(Arrays.asList("A")));
skippableSubjectSubfields.put("045N", Utils.listToMap(Arrays.asList("9", "V", "7", "3", "w")));
skippableSubjectSubfields.put("045R", Utils.listToMap(Arrays.asList("9", "V", "7", "3", "w")));
skippableSubjectSubfields.put("045T", Utils.listToMap(Arrays.asList("9", "V", "7", "3", "w")));

authorityTagsMap = new EnumMap<>(AuthorityCategory.class);
authorityTagsMap.put(AuthorityCategory.TITLES, List.of("022A", "022A"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ private void initialize() {
schemes.put("LoC Subject Headings", "lcsh0");
schemes.put("Regensburger Verbundklassifikation (RVK)", "rvk");
schemes.put("Medical Subject Headings (MeSH)", "mesh");
schemes.put("Klassifikation der National Library of Medicine (NLM)", "mesh");
}

public String resolve(String key) {
Expand Down

0 comments on commit ea9e2a5

Please sign in to comment.