aboutsummaryrefslogtreecommitdiffstats
path: root/mcgoron.ris.data.scm
blob: 83af5244c935e3186cbd65b01e23e91daf43cf3d (plain) (blame)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#| 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))