change_the_subject 0.3.6 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -1
- data/.gitignore +1 -0
- data/.rubocop.yml +3 -0
- data/.tool-versions +1 -1
- data/Gemfile.lock +24 -20
- data/change_the_subject.gemspec +1 -1
- data/config/change_the_subject.yml +113 -112
- data/lib/change_the_subject/version.rb +1 -1
- data/lib/change_the_subject.rb +49 -25
- metadata +5 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6e373737bb3c1301c451f662a9946ef5a6802350b62e5d9b3a6b77a22502677
|
4
|
+
data.tar.gz: a02f0e85465c778a9c2b23a34baf994878d98bf7e591fa347c88ddbb7139bf8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9c1afd0dde80243aad3f0950ccc8b3836bec7f2388a192ce0a3ebaea6d258ac02cdc0eaf8c9b8dfda00ad8e08a72d428bb1b9fdbbdb98f1f59966599a97205a
|
7
|
+
data.tar.gz: 8d6d05781d163a4c23bb556ce84b58fd5b013d3f2ef217e7524861e42751a9b91073f3a6784c29037bae07c863a14be4145ab3855cfff536f4794f127d0ea297
|
data/.circleci/config.yml
CHANGED
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 3.1
|
1
|
+
ruby 3.4.1
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
change_the_subject (0.
|
4
|
+
change_the_subject (0.4.0)
|
5
5
|
yaml
|
6
6
|
|
7
7
|
GEM
|
@@ -12,22 +12,24 @@ GEM
|
|
12
12
|
coderay (1.1.3)
|
13
13
|
diff-lcs (1.5.0)
|
14
14
|
docile (1.4.0)
|
15
|
-
json (2.
|
15
|
+
json (2.10.1)
|
16
|
+
language_server-protocol (3.17.0.4)
|
17
|
+
lint_roller (1.1.0)
|
16
18
|
method_source (1.0.0)
|
17
|
-
parallel (1.
|
18
|
-
parser (3.
|
19
|
+
parallel (1.26.3)
|
20
|
+
parser (3.3.7.1)
|
19
21
|
ast (~> 2.4.1)
|
22
|
+
racc
|
20
23
|
pry (0.14.1)
|
21
24
|
coderay (~> 1.1)
|
22
25
|
method_source (~> 1.0)
|
23
26
|
pry-byebug (3.10.1)
|
24
27
|
byebug (~> 11.0)
|
25
28
|
pry (>= 0.13, < 0.15)
|
29
|
+
racc (1.8.1)
|
26
30
|
rainbow (3.1.1)
|
27
31
|
rake (13.0.6)
|
28
|
-
regexp_parser (2.
|
29
|
-
rexml (3.2.8)
|
30
|
-
strscan (>= 3.0.9)
|
32
|
+
regexp_parser (2.10.0)
|
31
33
|
rspec (3.11.0)
|
32
34
|
rspec-core (~> 3.11.0)
|
33
35
|
rspec-expectations (~> 3.11.0)
|
@@ -41,30 +43,32 @@ GEM
|
|
41
43
|
diff-lcs (>= 1.2.0, < 2.0)
|
42
44
|
rspec-support (~> 3.11.0)
|
43
45
|
rspec-support (3.11.1)
|
44
|
-
rubocop (1.
|
46
|
+
rubocop (1.72.0)
|
45
47
|
json (~> 2.3)
|
48
|
+
language_server-protocol (~> 3.17.0.2)
|
49
|
+
lint_roller (~> 1.1.0)
|
46
50
|
parallel (~> 1.10)
|
47
|
-
parser (>= 3.
|
51
|
+
parser (>= 3.3.0.2)
|
48
52
|
rainbow (>= 2.2.2, < 4.0)
|
49
|
-
regexp_parser (>=
|
50
|
-
|
51
|
-
rubocop-ast (>= 1.20.1, < 2.0)
|
53
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
54
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
52
55
|
ruby-progressbar (~> 1.7)
|
53
|
-
unicode-display_width (>=
|
54
|
-
rubocop-ast (1.
|
55
|
-
parser (>= 3.
|
56
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
57
|
+
rubocop-ast (1.38.0)
|
58
|
+
parser (>= 3.3.1.0)
|
56
59
|
rubocop-rspec (2.13.1)
|
57
60
|
rubocop (~> 1.33)
|
58
|
-
ruby-progressbar (1.
|
61
|
+
ruby-progressbar (1.13.0)
|
59
62
|
simplecov (0.21.2)
|
60
63
|
docile (~> 1.1)
|
61
64
|
simplecov-html (~> 0.11)
|
62
65
|
simplecov_json_formatter (~> 0.1)
|
63
66
|
simplecov-html (0.12.3)
|
64
67
|
simplecov_json_formatter (0.1.4)
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
+
unicode-display_width (3.1.4)
|
69
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
70
|
+
unicode-emoji (4.0.4)
|
71
|
+
yaml (0.4.0)
|
68
72
|
|
69
73
|
PLATFORMS
|
70
74
|
arm64-darwin-21
|
@@ -77,7 +81,7 @@ DEPENDENCIES
|
|
77
81
|
pry-byebug
|
78
82
|
rake (~> 13.0)
|
79
83
|
rspec (~> 3.0)
|
80
|
-
rubocop (= 1.
|
84
|
+
rubocop (= 1.72)
|
81
85
|
rubocop-rspec
|
82
86
|
simplecov
|
83
87
|
|
data/change_the_subject.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.add_development_dependency "rake", "~> 13.0"
|
32
32
|
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
-
spec.add_development_dependency "rubocop", "1.
|
33
|
+
spec.add_development_dependency "rubocop", "1.72"
|
34
34
|
spec.add_development_dependency "rubocop-rspec"
|
35
35
|
spec.add_development_dependency "simplecov"
|
36
36
|
end
|
@@ -1,112 +1,113 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
"
|
5
|
-
|
6
|
-
|
7
|
-
"
|
8
|
-
|
9
|
-
|
10
|
-
"
|
11
|
-
|
12
|
-
|
13
|
-
"
|
14
|
-
|
15
|
-
|
16
|
-
"
|
17
|
-
|
18
|
-
|
19
|
-
"
|
20
|
-
|
21
|
-
|
22
|
-
"
|
23
|
-
|
24
|
-
|
25
|
-
"
|
26
|
-
|
27
|
-
|
28
|
-
"
|
29
|
-
|
30
|
-
|
31
|
-
"
|
32
|
-
|
33
|
-
|
34
|
-
"
|
35
|
-
|
36
|
-
|
37
|
-
"
|
38
|
-
|
39
|
-
|
40
|
-
"
|
41
|
-
|
42
|
-
|
43
|
-
"
|
44
|
-
|
45
|
-
|
46
|
-
"
|
47
|
-
|
48
|
-
|
49
|
-
"
|
50
|
-
|
51
|
-
|
52
|
-
"
|
53
|
-
|
54
|
-
|
55
|
-
"
|
56
|
-
|
57
|
-
|
58
|
-
"
|
59
|
-
|
60
|
-
|
61
|
-
"
|
62
|
-
|
63
|
-
|
64
|
-
"
|
65
|
-
|
66
|
-
|
67
|
-
"Indians"
|
68
|
-
|
69
|
-
|
70
|
-
"Indians
|
71
|
-
|
72
|
-
|
73
|
-
"
|
74
|
-
|
75
|
-
|
76
|
-
"
|
77
|
-
|
78
|
-
|
79
|
-
"
|
80
|
-
|
81
|
-
|
82
|
-
"
|
83
|
-
|
84
|
-
|
85
|
-
"
|
86
|
-
|
87
|
-
|
88
|
-
"Gender identity
|
89
|
-
|
90
|
-
|
91
|
-
"Gender identity
|
92
|
-
|
93
|
-
|
94
|
-
"
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
"
|
111
|
-
|
112
|
-
|
1
|
+
main_term:
|
2
|
+
"Illegal aliens":
|
3
|
+
replacement: "Undocumented immigrants"
|
4
|
+
rationale: "The term immigrant or undocumented/unauthorized immigrants are the terms LoC proposed as replacements for illegal aliens and other uses of the world alien in LCSH."
|
5
|
+
"Women illegal aliens":
|
6
|
+
replacement: "Women undocumented immigrants"
|
7
|
+
rationale: "The term immigrant or undocumented/unauthorized immigrants are the terms LoC proposed as replacements for illegal aliens and other uses of the world alien in LCSH."
|
8
|
+
"Illegal aliens in literature":
|
9
|
+
replacement: "Undocumented immigrants in literature"
|
10
|
+
rationale: "The term immigrant or undocumented/unauthorized immigrants are the terms LoC proposed as replacements for illegal aliens and other uses of the world alien in LCSH."
|
11
|
+
"Children of illegal aliens":
|
12
|
+
replacement: "Children of undocumented immigrants"
|
13
|
+
rationale: "The term immigrant or undocumented/unauthorized immigrants are the terms LoC proposed as replacements for illegal aliens and other uses of the world alien in LCSH."
|
14
|
+
"Illegal alien children":
|
15
|
+
replacement: "Undocumented immigrant children"
|
16
|
+
rationale: "The term immigrant or undocumented/unauthorized immigrants are the terms LoC proposed as replacements for illegal aliens and other uses of the world alien in LCSH."
|
17
|
+
"Illegal immigration":
|
18
|
+
replacement: "Undocumented immigrants"
|
19
|
+
rationale: "The term immigrant or undocumented/unauthorized immigrants are the terms LoC proposed as replacements for illegal aliens and other uses of the world alien in LCSH."
|
20
|
+
"Illegal immigration in literature":
|
21
|
+
replacement: "Undocumented immigrants in literature"
|
22
|
+
rationale: "The term immigrant or undocumented/unauthorized immigrants are the terms LoC proposed as replacements for illegal aliens and other uses of the world alien in LCSH."
|
23
|
+
"Alien criminals":
|
24
|
+
replacement: "Noncitizen criminals"
|
25
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
26
|
+
"Aliens":
|
27
|
+
replacement: "Noncitizens"
|
28
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
29
|
+
"Aliens in art":
|
30
|
+
replacement: "Noncitizens in art"
|
31
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
32
|
+
"Aliens in literature":
|
33
|
+
replacement: "Noncitizens in literature"
|
34
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
35
|
+
"Aliens in mass media":
|
36
|
+
replacement: "Noncitizens in mass media"
|
37
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
38
|
+
"Church work with aliens":
|
39
|
+
replacement: "Church work with noncitizens"
|
40
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
41
|
+
"Officials and employees, Alien":
|
42
|
+
replacement: "Officials and employees, Noncitizen"
|
43
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
44
|
+
"Aliens (Greek law)":
|
45
|
+
replacement: "Noncitizens (Greek law)"
|
46
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
47
|
+
"Aliens (Roman law)":
|
48
|
+
replacement: "Noncitizens (Roman law)"
|
49
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
50
|
+
"Child slaves":
|
51
|
+
replacement: "Enslaved children"
|
52
|
+
rationale: "In addition to its usage by TRLN, this term falls in line with recommendations included in the community-sourced document P. Gabrielle Foreman, et al. \"Writing about Slavery/Teaching About Slavery: This Might Help\" and Archives for Black Lives in Philadelphia Anti-Racist Description Resources."
|
53
|
+
"Indian slaves":
|
54
|
+
replacement: "Enslaved Indigenous peoples"
|
55
|
+
rationale: "In addition to its usage by TRLN, this term falls in line with recommendations included in the community-sourced document P. Gabrielle Foreman, et al. \"Writing about Slavery/Teaching About Slavery: This Might Help.\" Capitalization of \"Indigenous\" appears to be preferred by those from Indigenous communities, for example see https://www.lib.sfu.ca/about/branches-depts/slc/writing/inclusive-antiracist-writing/bipoc and https://www.ictinc.ca/blog/indigenous-peoples-terminology-guidelines-for-usage. As this is a broad term, when possible, one should include the name of the community(ies) or nation(s) of the people in the record. "
|
56
|
+
"Older slaves":
|
57
|
+
replacement: "Enslaved older people"
|
58
|
+
rationale: "The use of \"enslaved\" falls in line with recommendations included in the community-sourced document P. Gabrielle Foreman, et al. \"Writing about Slavery/Teaching About Slavery: This Might Help\" and Archives for Black Lives in Philadelphia Anti-Racist Description Resources. \"Older people\" is the current LC preferred term: https://id.loc.gov/search/?q=memberOf:http://id.loc.gov/authorities/demographicTerms/collection_LCDGT_Age. "
|
59
|
+
"Slaves":
|
60
|
+
replacement: "Enslaved persons"
|
61
|
+
rationale: "In addition to its usage by TRLN, this term falls in line with recommendations included in the community-sourced document P. Gabrielle Foreman, et al. \"Writing about Slavery/Teaching About Slavery: This Might Help\" and Archives for Black Lives in Philadelphia Anti-Racist Description Resources."
|
62
|
+
"Women slaves":
|
63
|
+
replacement: "Enslaved women"
|
64
|
+
rationale: "In addition to its usage by TRLN, this term falls in line with recommendations included in the community-sourced document P. Gabrielle Foreman, et al. \"Writing about Slavery/Teaching About Slavery: This Might Help\" and Archives for Black Lives in Philadelphia Anti-Racist Description Resources."
|
65
|
+
"East Indians":
|
66
|
+
replacement: "Indians (India)"
|
67
|
+
rationale: "\"East Indians\" is anachronistic and confusing to researchers. \"East\" is not used with \"Indians\" by the people who live in India, people who once lived in India, or even by the former colonizers of India at this point in time."
|
68
|
+
"Indians":
|
69
|
+
replacement: "Indigenous peoples of the Western Hemisphere"
|
70
|
+
rationale: "Using the scope note from the LCSH term, rather than the term \"Indians,\" is more accurate and less offensive for so many people under this large geographical umbrella."
|
71
|
+
"Indians of Central America":
|
72
|
+
replacement: "Indigenous peoples of Central America"
|
73
|
+
rationale: "This term is used by TRLN; according to our research, this terminology is preferred and widely regarded as a more inclusive term. It is important to include the geographic region in the subject term when possible, as there are Indigenous peoples throughout the world. When possible, it is respectful to also include the name of the community(ies) or nation(s) of the people in the record, for example \"Chumash,\" \"Tonkawa,\" \"Rapa Nui,\" \"Huetar.\""
|
74
|
+
"Indians of Mexico":
|
75
|
+
replacement: "Indigenous peoples of Mexico"
|
76
|
+
rationale: "This term is used by TRLN; according to our research, this terminology is preferred and widely regarded as a more inclusive term. It is important to include the geographic region in the subject term when possible, as there are Indigenous peoples throughout the world. When possible, it is respectful to also include the name of the community(ies) or nation(s) of the people in the record, for example \"Chumash,\" \"Tonkawa,\" \"Rapa Nui,\" \"Huetar.\""
|
77
|
+
"Indians of North America":
|
78
|
+
replacement: "Indigenous peoples of North America"
|
79
|
+
rationale: "This term is used by TRLN; according to our research, this terminology is preferred and widely regarded as a more inclusive term. It is important to include the geographic region in the subject term when possible, as there are Indigenous peoples throughout the world. When possible, it is respectful to also include the name of the community(ies) or nation(s) of the people in the record, for example \"Chumash,\" \"Tonkawa,\" \"Rapa Nui,\" \"Huetar.\""
|
80
|
+
"Indians of South America":
|
81
|
+
replacement: "Indigenous peoples of South America"
|
82
|
+
rationale: "This term is used by TRLN; according to our research, this terminology is preferred and widely regarded as a more inclusive term. It is important to include the geographic region in the subject term when possible, as there are Indigenous peoples throughout the world. When possible, it is respectful to also include the name of the community(ies) or nation(s) of the people in the record, for example \"Chumash,\" \"Tonkawa,\" \"Rapa Nui,\" \"Huetar.\""
|
83
|
+
"Indians of the West Indies":
|
84
|
+
replacement: "Indigenous peoples of the West Indies"
|
85
|
+
rationale: "This term is used by TRLN; according to our research, this terminology is preferred and widely regarded as a more inclusive term. It is important to include the geographic region in the subject term when possible, as there are Indigenous peoples throughout the world. When possible, it is respectful to also include the name of the community(ies) or nation(s) of the people in the record, for example \"Chumash,\" \"Tonkawa,\" \"Rapa Nui,\" \"Huetar.\""
|
86
|
+
"Gender identity disorders":
|
87
|
+
replacement: "Gender dysphoria"
|
88
|
+
rationale: '"Gender identity disorder" was removed from the DSM -- the primary diagnostic manual used by psychiatric and psychological professionals in the U.S. -- nearly a decade ago, and replaced with "Gender dysphoria."'
|
89
|
+
"Gender identity disorders in children":
|
90
|
+
replacement: "Gender dysphoria in children"
|
91
|
+
rationale: '"Gender identity disorder" was removed from the DSM -- the primary diagnostic manual used by psychiatric and psychological professionals in the U.S. -- nearly a decade ago, and replaced with "Gender dysphoria."'
|
92
|
+
"Gender identity disorders in adolescence":
|
93
|
+
replacement: "Gender dysphoria in adolescence"
|
94
|
+
rationale: '"Gender identity disorder" was removed from the DSM -- the primary diagnostic manual used by psychiatric and psychological professionals in the U.S. -- nearly a decade ago, and replaced with "Gender dysphoria."'
|
95
|
+
"Gays":
|
96
|
+
replacement: "Gay people"
|
97
|
+
rationale: "This subject heading has been updated by the Library of Congress, but some partner records have not yet been updated to reflect this."
|
98
|
+
"Convict labor":
|
99
|
+
replacement: "Prison labor"
|
100
|
+
rationale: "Prison labor is currently listed in LCSH as a variant of the authorized heading Convict labor. However, Convict labor appears to have become less commonly used and prison labor to have a broader historical scope. This title change was recommended by the Prison Teaching Initiative at Princeton."
|
101
|
+
"McKinley, Mount (Alaska)":
|
102
|
+
replacement: "Denali, Mount (Alaska)"
|
103
|
+
rationale: 'Denali is one of many long-standing Native names for this mountain, the name in common usage in Alaska, and the name with the most literary warrant. The Alaska Legislature has consistently requested that this mountain be called "Denali" since 1975, which was reaffirmed again in 2025. On the other hand, the name Mount McKinley had only been in use since 1896, in honor of a man who never set foot in Alaska or had any connection to the mountain. LCSH changed the authorized heading to "Denali, Mount (Alaska)" in 2015, and there is no need to change it back to the less common, less accurate name.'
|
104
|
+
"America, Gulf of":
|
105
|
+
replacement: "Mexico, Gulf of"
|
106
|
+
rationale: 'The term "Mexico, Gulf of" reflects literary warrant as well as colloquial usage patterns, and the term "America, Gulf of" is politically contested.'
|
107
|
+
subdivision:
|
108
|
+
"America, Gulf of":
|
109
|
+
replacement: "Mexico, Gulf of"
|
110
|
+
rationale: 'The term "Mexico, Gulf of" reflects literary warrant as well as colloquial usage patterns, and the term "America, Gulf of" is politically contested.'
|
111
|
+
"Evacuation and relocation, 1942-1945":
|
112
|
+
replacement: "Forced removal and internment, 1942-1945"
|
113
|
+
rationale: "This subdivision has been updated by the Library of Congress, but some partner records have not yet been updated to reflect this."
|
data/lib/change_the_subject.rb
CHANGED
@@ -20,22 +20,23 @@ class ChangeTheSubject
|
|
20
20
|
@separators = separators || ["—"]
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
@
|
23
|
+
def main_term_mapping
|
24
|
+
@main_term_mapping ||= config["main_term"]
|
25
|
+
end
|
26
|
+
|
27
|
+
def subdivision_term_mapping
|
28
|
+
@subdivision_term_mapping ||= config["subdivision"]
|
25
29
|
end
|
26
30
|
|
27
31
|
# Given an array of subject terms, replace the ones that need replacing
|
28
32
|
# @param [<String>] subject_terms
|
29
33
|
# @return [<String>]
|
30
34
|
def fix(subject_terms:)
|
31
|
-
|
32
|
-
|
33
|
-
subject_terms = subject_terms.compact.reject(&:empty?)
|
34
|
-
return [] if subject_terms.empty? || subject_terms.nil?
|
35
|
-
|
36
|
-
subject_terms.map do |term|
|
35
|
+
subject_terms.compact.reject(&:empty?).map do |term|
|
37
36
|
replacement = check_for_replacement(term: term)
|
38
|
-
|
37
|
+
subdivision_replacement = check_for_replacement_subdivision(term: replacement)
|
38
|
+
|
39
|
+
subdivision_replacement unless subdivision_replacement.empty?
|
39
40
|
end.compact.uniq
|
40
41
|
end
|
41
42
|
|
@@ -46,7 +47,7 @@ class ChangeTheSubject
|
|
46
47
|
def check_for_replacement(term:)
|
47
48
|
separators.each do |separator|
|
48
49
|
subterms = term.split(separator)
|
49
|
-
replacement =
|
50
|
+
replacement = replacement_config_for_main_terms(subterms)
|
50
51
|
next unless replacement
|
51
52
|
|
52
53
|
new_terms = replacement_terms(replacement)
|
@@ -58,13 +59,47 @@ class ChangeTheSubject
|
|
58
59
|
term
|
59
60
|
end
|
60
61
|
|
62
|
+
def check_for_replacement_subdivision(term:)
|
63
|
+
separators.each do |separator|
|
64
|
+
next unless term.include?(separator)
|
65
|
+
|
66
|
+
return replace_subdivisions(term: term, separator: separator)
|
67
|
+
end
|
68
|
+
term
|
69
|
+
end
|
70
|
+
|
71
|
+
def replace_subdivisions(term:, separator:)
|
72
|
+
subterms = term.split(separator)
|
73
|
+
subterms.each.with_index do |sub_term, index|
|
74
|
+
next if index.zero?
|
75
|
+
|
76
|
+
term_config = subdivision_term_mapping[sub_term]
|
77
|
+
next unless term_config
|
78
|
+
|
79
|
+
subterms[index] = term_config["replacement"]
|
80
|
+
end
|
81
|
+
|
82
|
+
subterms.join(separator)
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.config_yaml
|
86
|
+
change_the_subject_erb = ERB.new(File.read(change_the_subject_config_file)).result
|
87
|
+
YAML.safe_load(change_the_subject_erb, aliases: true)
|
88
|
+
rescue StandardError, SyntaxError => error
|
89
|
+
raise Error, "#{change_the_subject_config_file} was found, but could not be parsed. \n#{error.inspect}"
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.change_the_subject_config_file
|
93
|
+
File.join(File.dirname(__FILE__), "../", "config", "change_the_subject.yml")
|
94
|
+
end
|
95
|
+
|
61
96
|
private
|
62
97
|
|
63
|
-
def
|
64
|
-
matching_key =
|
98
|
+
def replacement_config_for_main_terms(subterms)
|
99
|
+
matching_key = main_term_mapping.keys.find do |term_to_replace|
|
65
100
|
term_matches_subterms?(term_to_replace, subterms)
|
66
101
|
end
|
67
|
-
|
102
|
+
main_term_mapping[matching_key] if matching_key
|
68
103
|
end
|
69
104
|
|
70
105
|
def term_matches_subterms?(term, subterms)
|
@@ -79,17 +114,6 @@ class ChangeTheSubject
|
|
79
114
|
end
|
80
115
|
|
81
116
|
def config
|
82
|
-
@config ||= config_yaml
|
83
|
-
end
|
84
|
-
|
85
|
-
def config_yaml
|
86
|
-
change_the_subject_erb = ERB.new(File.read(change_the_subject_config_file)).result
|
87
|
-
YAML.safe_load(change_the_subject_erb, aliases: true)
|
88
|
-
rescue StandardError, SyntaxError => e
|
89
|
-
raise Error, "#{change_the_subject_config_file} was found, but could not be parsed. \n#{e.inspect}"
|
90
|
-
end
|
91
|
-
|
92
|
-
def change_the_subject_config_file
|
93
|
-
File.join(File.dirname(__FILE__), "../", "config", "change_the_subject.yml")
|
117
|
+
@config ||= ChangeTheSubject.config_yaml
|
94
118
|
end
|
95
119
|
end
|
metadata
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: change_the_subject
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Kadel
|
8
8
|
- Anna Headley
|
9
9
|
- Trey Pendragon
|
10
10
|
- Eliot Jordan
|
11
|
-
autorequire:
|
12
11
|
bindir: exe
|
13
12
|
cert_chain: []
|
14
|
-
date:
|
13
|
+
date: 2025-02-20 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: yaml
|
@@ -61,14 +60,14 @@ dependencies:
|
|
61
60
|
requirements:
|
62
61
|
- - '='
|
63
62
|
- !ruby/object:Gem::Version
|
64
|
-
version: '1.
|
63
|
+
version: '1.72'
|
65
64
|
type: :development
|
66
65
|
prerelease: false
|
67
66
|
version_requirements: !ruby/object:Gem::Requirement
|
68
67
|
requirements:
|
69
68
|
- - '='
|
70
69
|
- !ruby/object:Gem::Version
|
71
|
-
version: '1.
|
70
|
+
version: '1.72'
|
72
71
|
- !ruby/object:Gem::Dependency
|
73
72
|
name: rubocop-rspec
|
74
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -97,7 +96,6 @@ dependencies:
|
|
97
96
|
- - ">="
|
98
97
|
- !ruby/object:Gem::Version
|
99
98
|
version: '0'
|
100
|
-
description:
|
101
99
|
email:
|
102
100
|
- digital-library@princeton.libanswers.com
|
103
101
|
executables: []
|
@@ -127,7 +125,6 @@ metadata:
|
|
127
125
|
allowed_push_host: https://rubygems.org
|
128
126
|
homepage_uri: https://github.com/pulibrary/change_the_subject
|
129
127
|
source_code_uri: https://github.com/pulibrary/change_the_subject
|
130
|
-
post_install_message:
|
131
128
|
rdoc_options: []
|
132
129
|
require_paths:
|
133
130
|
- lib
|
@@ -142,8 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
139
|
- !ruby/object:Gem::Version
|
143
140
|
version: '0'
|
144
141
|
requirements: []
|
145
|
-
rubygems_version: 3.
|
146
|
-
signing_key:
|
142
|
+
rubygems_version: 3.6.2
|
147
143
|
specification_version: 4
|
148
144
|
summary: Provides configuration and utilities for replacing archaic subject terms
|
149
145
|
with preferred subject terms
|