Remove duplicates from credits

This commit is contained in:
2023-05-24 20:18:20 -06:00
parent 7bcc35578c
commit 9855358c80

View File

@@ -621,6 +621,8 @@
(for line (.split .content (Stream.fromString creditsTSV) "\n") (line.split "\t"))
headings
[]
edgeCaseCredits
(new Map<String,String>)
headingIndices
(new Map<String,Int>)
headingData
@@ -643,15 +645,26 @@
(case data
([heading credit _sourceOrUrl]
(ifLet [idx (dictGet headingIndices heading)]
(let [hd (dictGet headingData heading)
(let [edgeCaseCredit (dictGet edgeCaseCredits heading)
hd (dictGet headingData heading)
// Push unless given a duplicate:
hdPush ->:Void data
(let [dataStr (data.toString)]
(when (= credit edgeCaseCredit)
(return))
(doFor d hd
(when (= (d.toString) dataStr)
(return)))
(hd.push data))
headingLineData (nth creditsData idx)]
(case headingLineData
([heading ""]
(dictSet edgeCaseCredits heading credit)
(setNth headingLineData 1 credit))
(["" heading]
(hd.push ["" " ${credit}"]))
(hdPush ["" " ${credit}"]))
((or [heading] [heading _])
(hd.push ["" credit]))
(hdPush ["" credit]))
(never otherwise)))
(throw "no heading $heading to place credit $data")))