#| Copyright 2024 Peter McGoron | | Licensed under the Apache License, Version 2.0 (the "License"); | | you may not use this file except in compliance with the License. | You may obtain a copy of the License at | | http://www.apache.org/licenses/LICENSE-2.0 | | Unless required by applicable law or agreed to in writing, software | distributed under the License is distributed on an "AS IS" BASIS, | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | See the License for the specific language governing permissions and | limitations under the License. |------------------------------------------------------------------------| | This file implements mapping from RIS codes to English descriptions. | The sets and maps are implemented as parameters so they can be changed | for any non-standard RIS files. |# ;;; Utility functions. (define (make-mapping-parameter default) (make-parameter default (lambda (x) (cond ((mapping? x) x) ((pair? x) (alist->mapping (make-default-comparator) x)) (else (error "parameter must be a map" x)))))) (define (make-set-parameter default) (make-parameter default (lambda (x) (cond ((set? x) x) ((pair? x) (list->set (make-default-comparator) x)) (else (error "parameter must be a set" x)))))) (define (parameter-lookup param) (lambda (x) (mapping-ref/default (param) x #f))) ;;; Standard author fields. ;;; There are 4 author fields, but some information about the authors ;;; can be interleaved in with the author fields (for instance, "AD", ;;; author address). ;;; ;;; To work around this bad design choice, all authors are put into a ;;; meta-field "AUTHORS" which deliberately does not conform to the RIS ;;; format. ;;; ;;; This should have been a nested format like sexprs or JSON. At least ;;; it's not XML. (define author-fields (make-set-parameter '("AU" "A2" "A3" "A4"))) (define (author-field? x) (set-contains? (author-fields) x)) ;;; Maps from standard type and field codes to their descriptions. (define type-codes (make-mapping-parameter '(("GEN" . "Generic") ("ART" . "Artwork") ("ABST" . "Abstract") ("AGGR" . "Aggregated Database") ("ANCIENT" . "Ancient Text") ("ADVS" . "Audiovisual Material") ("BILL" . "Bill") ("BLOG" . "Blog") ("BOOK" . "Book") ("CHAP" . "Book Section") ("CASE" . "Case") ("CTLG" . "Catalog") ("CHART" . "Chart") ("CLSWK" . "Classical Work") ("COMP" . "Computer Program") ("CPAPER" . "Conference Paper") ("CONF" . "Conference Proceeding") ("DATA" . "Dataset") ("DICT" . "Dictionary") ("EDBOOK" . "Edited Book") ("EBOOK" . "Electronic Book") ("ECHAP" . "Electronic Book Section") ("EJOUR" . "Electronic Article") ("ENCYC" . "Encyclopedia") ("EQUA" . "Equation") ("FIGURE" . "Figure") ("MPCT" . "Film or Broadcast") ("HEAR" . "Hearing") ("INPR" . "In Press Article") ("ICOMM" . "Internet Communication") ("JOUR" . "Journal Article") ("LEGAL" . "Legal Rule") ("MGZN" . "Magazine Article") ("MANSCPT" . "Manuscript") ("MAP" . "Map") ("MUSIC" . "Music") ("NEWS" . "Newspaper Article") ("DBASE" . "Online Database") ("MULTI" . "Online Multimedia") ("PAMP" . "Pamphlet") ("PAT" . "Patent") ("PCOMM" . "Personal Communication") ("RPRT" . "Report") ("SER" . "Serial") ("SLIDE" . "Slide") ("SOUND" . "Sound Recording") ("STAND" . "Standard") ("STAT" . "Statute") ("THES" . "Thesis") ("UNBILL" . "Unenacted Bill") ("UNPD" . "Unpublished Work") ("VIDEO" . "Video Recording") ("ELEC" . "Web Page")))) (define ris-type-name (parameter-lookup type-codes)) (define field-codes (make-mapping-parameter '(("TY" . "GEN") ("A2" . "Secondary Author") ("A3" . "Tertiary Author") ("A4" . "Subsidiary Author") ("AB" . "Abstract") ("AD" . "Author Address") ("AN" . "Accession Number") ("AU" . "Author") ("C1" . "Custom 1") ("C2" . "Custom 2") ("C3" . "Custom 3") ("C4" . "Custom 4") ("C5" . "Custom 5") ("C6" . "Custom 6") ("C7" . "Custom 7") ("C8" . "Custom 8") ("CA" . "Call Number") ("CN" . "Caption") ("CY" . "Place Published") ("DA" . "Date") ("DB" . "Name of Database") ("DO" . "DOI") ("DP" . "Database Provider") ("ET" . "Edition") ("J2" . "Alternate Title") ("KW" . "Keywords") ("L1" . "File Attachments") ("L4" . "Language") ("LA" . "Figure") ("LB" . "Label") ("IS" . "Number") ("M3" . "Type of Work") ("N1" . "Notes") ("NV" . "Number of Volumes") ("OP" . "Original Publication") ("PB" . "Publisher") ("PY" . "Year")))) (define ris-field-name (parameter-lookup field-codes))