change_the_subject 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -2
- data/README.md +6 -0
- data/config/change_the_subject.yml +16 -0
- data/lib/change_the_subject/version.rb +1 -1
- data/lib/change_the_subject.rb +23 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8a0956d2724b06f4d4bf159ef8a92236bb040d689cb0ca886b262c14f3fdff3
|
4
|
+
data.tar.gz: 3fc1fb0de44f65beaa8823077e17679ee990d04a1cf9dc61774bd7598535dcfc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bf724643816e357bb6c80d5b386fc9ed6249edc07cab9ccfd4090ce1a02892a0a76c20d548574b452bece0651e8e6a8f5b47f04fef32e95e23b33f48ff0b2df
|
7
|
+
data.tar.gz: 5388b39ec7c4dd8456989b5a10ea66ea0d4deb28571e154e2316c78a1fdbb1431cf09f14f644ea1e208a8922d796cd90f8e0f43f77a79fd3ffb34838ade3c4a8
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
change_the_subject (0.3.
|
4
|
+
change_the_subject (0.3.5)
|
5
5
|
yaml
|
6
6
|
|
7
7
|
GEM
|
@@ -26,7 +26,8 @@ GEM
|
|
26
26
|
rainbow (3.1.1)
|
27
27
|
rake (13.0.6)
|
28
28
|
regexp_parser (2.5.0)
|
29
|
-
rexml (3.2.
|
29
|
+
rexml (3.2.8)
|
30
|
+
strscan (>= 3.0.9)
|
30
31
|
rspec (3.11.0)
|
31
32
|
rspec-core (~> 3.11.0)
|
32
33
|
rspec-expectations (~> 3.11.0)
|
@@ -61,6 +62,7 @@ GEM
|
|
61
62
|
simplecov_json_formatter (~> 0.1)
|
62
63
|
simplecov-html (0.12.3)
|
63
64
|
simplecov_json_formatter (0.1.4)
|
65
|
+
strscan (3.1.0)
|
64
66
|
unicode-display_width (2.3.0)
|
65
67
|
yaml (0.2.1)
|
66
68
|
|
data/README.md
CHANGED
@@ -37,6 +37,12 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
37
37
|
|
38
38
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
39
39
|
|
40
|
+
### Running the tests
|
41
|
+
|
42
|
+
```
|
43
|
+
bundle exec rspec
|
44
|
+
```
|
45
|
+
|
40
46
|
## Contributing
|
41
47
|
The configuration for this gem is managed by the Inclusive and Reparative Metadata Working Group (IRMWG). Send questions or comments about the configuration to harmfullanguage@princeton.libanswers.com.
|
42
48
|
|
@@ -91,3 +91,19 @@
|
|
91
91
|
"Gender identity disorders in adolescence":
|
92
92
|
replacement: "Gender dysphoria in adolescence"
|
93
93
|
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."'
|
94
|
+
"Gays":
|
95
|
+
replacement: "Gay people"
|
96
|
+
rationale: "This subject heading has been updated by the Library of Congress, but some partner records have not yet been updated to reflect this."
|
97
|
+
# The following term will match if the first two subfields in the field are "Japanese Americans" and "Evacuation and relocation, 1942-1945"
|
98
|
+
["Japanese Americans", "Evacuation and relocation, 1942-1945"]:
|
99
|
+
replacement: ["Japanese Americans", "Forced removal and internment, 1942-1945"]
|
100
|
+
rationale: "This subject heading has been updated by the Library of Congress, but some partner records have not yet been updated to reflect this."
|
101
|
+
["Aleuts", "Evacuation and relocation, 1942-1945"]:
|
102
|
+
replacement: ["Aleuts", "Forced removal and internment, 1942-1945"]
|
103
|
+
rationale: "This subject heading has been updated by the Library of Congress, but some partner records have not yet been updated to reflect this."
|
104
|
+
["German Americans", "Evacuation and relocation, 1942-1945"]:
|
105
|
+
replacement: ["German Americans", "Forced removal and internment, 1942-1945"]
|
106
|
+
rationale: "This subject heading has been updated by the Library of Congress, but some partner records have not yet been updated to reflect this."
|
107
|
+
["Italian Americans", "Evacuation and relocation, 1942-1945"]:
|
108
|
+
replacement: ["Italian Americans", "Forced removal and internment, 1942-1945"]
|
109
|
+
rationale: "This subject heading 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
@@ -46,13 +46,13 @@ class ChangeTheSubject
|
|
46
46
|
def check_for_replacement(term:)
|
47
47
|
separators.each do |separator|
|
48
48
|
subterms = term.split(separator)
|
49
|
-
|
50
|
-
replacement = terms_mapping[subfield_a]
|
49
|
+
replacement = replacement_config_for_subterms(subterms)
|
51
50
|
next unless replacement
|
52
51
|
|
53
|
-
|
54
|
-
subterms.
|
55
|
-
|
52
|
+
new_terms = replacement_terms(replacement)
|
53
|
+
return subterms.drop(new_terms.count)
|
54
|
+
.prepend(new_terms)
|
55
|
+
.join(separator)
|
56
56
|
end
|
57
57
|
|
58
58
|
term
|
@@ -60,6 +60,24 @@ class ChangeTheSubject
|
|
60
60
|
|
61
61
|
private
|
62
62
|
|
63
|
+
def replacement_config_for_subterms(subterms)
|
64
|
+
matching_key = terms_mapping.keys.find do |term_to_replace|
|
65
|
+
term_matches_subterms?(term_to_replace, subterms)
|
66
|
+
end
|
67
|
+
return terms_mapping[matching_key] if matching_key
|
68
|
+
end
|
69
|
+
|
70
|
+
def term_matches_subterms?(term, subterms)
|
71
|
+
term_as_array = Array(term)
|
72
|
+
term_as_array.count.times.all? do |index|
|
73
|
+
term_as_array[index] == subterms[index]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def replacement_terms(configured_term)
|
78
|
+
Array(configured_term["replacement"])
|
79
|
+
end
|
80
|
+
|
63
81
|
def config
|
64
82
|
@config ||= config_yaml
|
65
83
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: change_the_subject
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Kadel
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2024-07-09 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: yaml
|