Skip to content

Commit

Permalink
remediated headings can have more than one field
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed May 22, 2024
1 parent e3b0c2e commit ce39d63
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/authority_browse/remediated_subjects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def loc_id
end

def label
@record["150"]["a"]
@record["150"].subfields.map { |x| x.value }.join("--")
end

def match_text
Expand Down
8 changes: 4 additions & 4 deletions spec/authority_browse/remediated_subjects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
described_class.new(fixture("remediated_subject.xml"))
end
it "returns the mms_id for the #id" do
expect(subject.id).to eq("98187481368106381")
expect(subject.id).to eq("98187481368506381")
end

it "returns the url for the #loc_id (minus the extension) from 010$a" do
expect(subject.loc_id).to eq("http://id.loc.gov/authorities/subjects/sh85003553")
expect(subject.loc_id).to eq("http://id.loc.gov/authorities/subjects/sh2008104250")
end

it "returns the #label from 150$a" do
expect(subject.label).to eq("Undocumented immigrants")
expect(subject.label).to eq("Undocumented immigrants--Government policy--United States")
end

it "returns the #match_text of the label" do
expect(subject.match_text).to eq("undocumented immigrants")
expect(subject.match_text).to eq("undocumented immigrants--government policy--united states")
end
end
10 changes: 5 additions & 5 deletions spec/authority_browse/subjects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,18 +146,18 @@
it "handles adding remediated subjects" do
subjects = AuthorityBrowse.db[:subjects]
subxref = AuthorityBrowse.db[:subjects_xrefs]
mms_id = "98187481368106381"
loc_id = "http://id.loc.gov/authorities/subjects/sh85003553"
mms_id = "98187481368506381"
loc_id = "http://id.loc.gov/authorities/subjects/sh2008104250"

subjects.insert(id: "http://id.loc.gov/authorities/subjects/sh85003553", label: "Illegal Aliens", match_text: "illegal aliens", count: 0)
subjects.insert(id: loc_id, label: "Illegal Aliens", match_text: "illegal aliens", count: 0)
subjects.insert(id: "id2", label: "Second", match_text: "second", count: 2)
subxref.insert(subject_id: loc_id, xref_id: "id2", xref_kind: "broader")
subxref.insert(subject_id: "id2", xref_id: loc_id, xref_kind: "narrower")

AuthorityBrowse::Subjects.incorporate_remediated_subjects(File.join(S.project_root, "spec", "fixtures", "remediated_subject.xml"))
remediated = subjects.where(id: mms_id).first
expect(remediated[:label]).to eq("Undocumented immigrants")
expect(remediated[:match_text]).to eq("undocumented immigrants")
expect(remediated[:label]).to eq("Undocumented immigrants--Government policy--United States")
expect(remediated[:match_text]).to eq("undocumented immigrants--government policy--united states")

broader = subxref.where(subject_id: mms_id).first
expect(broader[:xref_id]).to eq("id2")
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/remediated_subject.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="UTF-16"?><record><leader>01200cz a2200301n 4500</leader><controlfield tag="005">20230329130030.0</controlfield><controlfield tag="008">030627i| anannbabn |a ana </controlfield><controlfield tag="001">98187481368106381</controlfield><datafield ind1=" " ind2=" " tag="010"><subfield code="a">sh 85003553</subfield></datafield><datafield ind1=" " ind2=" " tag="035"><subfield code="a">(DLC)sh 85003553</subfield></datafield><datafield ind1=" " ind2=" " tag="035"><subfield code="a">(LIBRARY_OF_CONGRESS)98171057700000041</subfield></datafield><datafield ind1=" " ind2=" " tag="040"><subfield code="a">DLC</subfield><subfield code="c">DLC</subfield><subfield code="d">DLC</subfield><subfield code="d">WaU</subfield></datafield><datafield ind1=" " ind2=" " tag="150"><subfield code="a">Undocumented immigrants</subfield></datafield><datafield ind1=" " ind2=" " tag="450"><subfield code="a">Undocumented foreign nationals</subfield></datafield><datafield ind1=" " ind2=" " tag="450"><subfield code="a">Illegal aliens</subfield></datafield><datafield ind1=" " ind2=" " tag="450"><subfield code="a">Aliens</subfield><subfield code="x">Legal status, laws, etc.</subfield></datafield><datafield ind1=" " ind2=" " tag="450"><subfield code="w">nne</subfield><subfield code="a">Aliens, Illegal</subfield></datafield><datafield ind1=" " ind2=" " tag="450"><subfield code="a">Illegal aliens</subfield><subfield code="x">Legal status, laws, etc.</subfield></datafield><datafield ind1=" " ind2=" " tag="450"><subfield code="a">Illegal immigrants</subfield></datafield><datafield ind1=" " ind2=" " tag="450"><subfield code="a">Undocumented noncitizens</subfield></datafield><datafield ind1=" " ind2=" " tag="550"><subfield code="w">g</subfield><subfield code="a">Aliens</subfield></datafield><datafield ind1=" " ind2=" " tag="550"><subfield code="a">Immigrant detention centers</subfield></datafield><datafield ind1=" " ind2=" " tag="550"><subfield code="a">Human smuggling</subfield></datafield><datafield ind1=" " ind2=" " tag="550"><subfield code="a">Noncitizens</subfield></datafield><datafield ind1=" " ind2=" " tag="550"><subfield code="a">Illegal immigration</subfield></datafield><datafield ind1=" " ind2=" " tag="670"><subfield code="a">Work cat.: 2007017970: Illegal immigration, 2007:</subfield><subfield code="b">eCIP data sheet (Illegal immigrants)</subfield></datafield><datafield ind1=" " ind2=" " tag="690"><subfield code="a">sla-lab updated based on DEIA Catalog Working Group changes May 2021; "Undocumented immigrants" term borrowed from Sears ; "undocumented foreign national" term from Bill H.R. 3776 (116th Congress)</subfield></datafield><datafield ind1=" " ind2=" " tag="690"><subfield code="a">sla-lab updated to include 550s for LCSH headings as references March 2023</subfield></datafield></record>
<?xml version="1.0" encoding="UTF-16"?><record><leader>00970nz a2200205n 4500</leader><controlfield tag="005">20230329130158.0</controlfield><controlfield tag="008">080211|| anannbabn |n ana </controlfield><controlfield tag="001">98187481368506381</controlfield><datafield ind1=" " ind2=" " tag="010"><subfield code="a">sh2008104250</subfield></datafield><datafield ind1=" " ind2=" " tag="035"><subfield code="a">(DLC) sh2008104250</subfield></datafield><datafield ind1=" " ind2=" " tag="035"><subfield code="a">(LIBRARY_OF_CONGRESS)98170331580000041</subfield></datafield><datafield ind1=" " ind2=" " tag="040"><subfield code="a">DLC</subfield><subfield code="b">eng</subfield><subfield code="c">DLC</subfield><subfield code="d">MiU</subfield></datafield><datafield ind1=" " ind2=" " tag="150"><subfield code="a">Undocumented immigrants</subfield><subfield code="x">Government policy</subfield><subfield code="z">United States</subfield></datafield><datafield ind1=" " ind2=" " tag="450"><subfield code="a">Undocumented foreign nationals</subfield><subfield code="z">United States</subfield></datafield><datafield ind1=" " ind2=" " tag="450"><subfield code="a">Illegal aliens</subfield><subfield code="x">Goverment policy</subfield><subfield code="z">United States</subfield></datafield><datafield ind1=" " ind2=" " tag="550"><subfield code="a">Noncitizens</subfield><subfield code="x">Government policy</subfield><subfield code="z">United States</subfield></datafield><datafield ind1=" " ind2=" " tag="667"><subfield code="a">Record generated for validation purposes.</subfield></datafield><datafield ind1=" " ind2=" " tag="670"><subfield code="a">Work cat.: Illegal immigration, c2001</subfield></datafield><datafield ind1=" " ind2=" " tag="690"><subfield code="a">sla-lab updated based on DEIA Catalog Working Group changes May 2021; "Undocumented immigrants" term borrowed from Sears ; "undocumented foreign national" term from Bill H.R. 3776 (116th Congress)</subfield></datafield><datafield ind1=" " ind2=" " tag="690"><subfield code="a">sla-lab updated to include 550s for LCSH headings as references March 2023</subfield></datafield></record>

0 comments on commit ce39d63

Please sign in to comment.