Fix order of result content
modules/nani/result/jibiki.scm
125 | 125 | (match (car lst) | |
126 | 126 | ((? string? s) | |
127 | 127 | (update-source source | |
128 | - | #:content (cons s (source-content source)))) | |
128 | + | #:content (append (source-content source) (list s)))) | |
129 | 129 | (('lang . l) | |
130 | 130 | (update-source source #:lang l)) | |
131 | 131 | ((? list? l) | |
… | |||
141 | 141 | (#f meaning) | |
142 | 142 | (('n . _) meaning) | |
143 | 143 | (('info . info) (update-meaning meaning | |
144 | - | #:infos (cons info (meaning-infos meaning)))) | |
144 | + | #:infos | |
145 | + | (append (meaning-infos meaning) (list info)))) | |
145 | 146 | (('content . c) (update-meaning meaning | |
146 | 147 | #:glosses (append | |
147 | - | (map string-downcase | |
148 | - | (string-split c #\,)) | |
149 | - | (meaning-glosses meaning)))) | |
148 | + | (meaning-glosses meaning) | |
149 | + | (string-split c #\,)))) | |
150 | 150 | ((? source? s) | |
151 | 151 | (update-meaning meaning | |
152 | - | #:sources (cons s (meaning-sources meaning)))) | |
152 | + | #:sources (append (meaning-sources meaning) (lit s)))) | |
153 | 153 | ((? string? _) meaning) | |
154 | 154 | ((? list? l) (loop l meaning))))))) | |
155 | 155 | ||
… | |||
166 | 166 | (('kanji . k) | |
167 | 167 | (loop (cdr lst) | |
168 | 168 | (update-result result | |
169 | - | #:kanjis (cons k (result-kanjis result))) | |
169 | + | #:kanjis (append (result-kanjis result) (list k))) | |
170 | 170 | infos | |
171 | 171 | sources)) | |
172 | 172 | ((? reading? r) | |
173 | 173 | (loop | |
174 | 174 | (cdr lst) | |
175 | 175 | (update-result result | |
176 | - | #:readings (cons r (result-readings result))) | |
176 | + | #:readings (append (result-readings result) (list r))) | |
177 | 177 | infos | |
178 | 178 | sources)) | |
179 | 179 | ((? meaning? s) | |
180 | 180 | (loop | |
181 | 181 | (cdr lst) | |
182 | 182 | (update-result result | |
183 | - | #:meanings (cons s (result-meanings result))) | |
183 | + | #:meanings (append (result-meanings result) (list s))) | |
184 | 184 | infos | |
185 | 185 | sources)) | |
186 | 186 | ((? source? s) | |
187 | - | (loop (cdr lst) result infos (cons s sources))) | |
187 | + | (loop (cdr lst) result infos (append sources (list s)))) | |
188 | 188 | (('info . info) | |
189 | 189 | (loop (cdr lst) | |
190 | 190 | result | |
191 | - | (cons info infos) | |
191 | + | (append infos (list info)) | |
192 | 192 | sources)) | |
193 | 193 | ((? list? l) | |
194 | 194 | (match (loop l result infos sources) |
modules/nani/result/jmdict.scm
34 | 34 | reading | |
35 | 35 | (loop | |
36 | 36 | (match (car lst) | |
37 | - | (('reading r) (update-reading reading #:readings (cons r (reading-readings reading)))) | |
38 | - | (('info r) (update-reading reading #:info (cons r (reading-info reading)))) | |
39 | - | (('limit r) (update-reading reading #:kanjis (cons r (reading-kanjis reading)))) | |
37 | + | (('reading r) (update-reading reading #:readings | |
38 | + | (append (reading-readings reading) (list r)))) | |
39 | + | (('info r) (update-reading reading #:info | |
40 | + | (append (reading-info reading) (list r)))) | |
41 | + | (('limit r) (update-reading reading #:kanjis | |
42 | + | (append (reading-kanjis reading) (list r)))) | |
40 | 43 | (((? symbol? s) v) (throw 'unknown-content s v)) | |
41 | 44 | ((? string? _) reading)) | |
42 | 45 | (cdr lst))))) | |
… | |||
47 | 50 | source | |
48 | 51 | (loop | |
49 | 52 | (match (car lst) | |
50 | - | (('content c) (update-source source #:content (cons c (source-content source)))) | |
53 | + | (('content c) (update-source source #:content | |
54 | + | (append (source-content source) (list c)))) | |
51 | 55 | (('ls_wasei _) (update-source source #:wasei? #t)) | |
52 | 56 | (('ls_type t) source); type is always "part" or nothing | |
53 | 57 | ((('xml . 'lang) l) (update-source source #:lang l)) | |
54 | 58 | (((? symbol? s) v) (throw 'unknown-content s v)) | |
55 | 59 | ((? list? l) (loop source l)) | |
56 | 60 | ((? string? c) (update-source source #:content | |
57 | - | (cons c (source-content source))))) | |
61 | + | (append (source-content source) (list c))))) | |
58 | 62 | (cdr lst))))) | |
59 | 63 | ||
60 | 64 | (define (sxml->meaning lst) | |
… | |||
63 | 67 | meaning | |
64 | 68 | (loop | |
65 | 69 | (match (car lst) | |
66 | - | (('ref (? string? r)) (update-meaning meaning #:references (cons r (meaning-references meaning)))) | |
67 | - | (('limit (? string? r)) (update-meaning meaning #:limits (cons r (meaning-limits meaning)))) | |
68 | - | (('info (? string? r)) (update-meaning meaning #:infos (cons r (meaning-infos meaning)))) | |
69 | - | ((? source? s) (update-meaning meaning #:sources (cons s (meaning-sources meaning)))) | |
70 | - | (('info (? string? r)) (update-meaning meaning #:infos (cons r (meaning-infos meaning)))) | |
71 | - | (('gloss (? string? r)) (update-meaning meaning | |
72 | - | #:glosses | |
73 | - | (cons (string-downcase r) | |
74 | - | (meaning-glosses meaning)))) | |
70 | + | (('ref (? string? r)) | |
71 | + | (update-meaning meaning #:references | |
72 | + | (append (meaning-references meaning) (list r)))) | |
73 | + | (('limit (? string? r)) | |
74 | + | (update-meaning meaning #:limits | |
75 | + | (append (meaning-limits meaning) (list r)))) | |
76 | + | (('info (? string? r)) | |
77 | + | (update-meaning meaning #:infos | |
78 | + | (append (meaning-infos meaning) (list r)))) | |
79 | + | ((? source? s) | |
80 | + | (update-meaning meaning #:sources | |
81 | + | (append (meaning-sources meaning) (list s)))) | |
82 | + | (('info (? string? r)) | |
83 | + | (update-meaning meaning #:infos | |
84 | + | (append (meaning-infos meaning) (list r)))) | |
85 | + | (('gloss (? string? r)) | |
86 | + | (update-meaning meaning #:glosses | |
87 | + | (append (meaning-glosses meaning) (list r)))) | |
75 | 88 | ((('xml . 'lang) (? string? l)) (update-meaning meaning #:language l)) | |
76 | 89 | (((? symbol? s) v) (throw 'unknown-content s v)) | |
77 | 90 | ((? list? l) (loop meaning l)) | |
… | |||
86 | 99 | (loop | |
87 | 100 | (match (car lst) | |
88 | 101 | (('kanji kanji) | |
89 | - | (update-result result #:kanjis (cons kanji (result-kanjis result)))) | |
102 | + | (update-result result #:kanjis | |
103 | + | (append (result-kanjis result) (list kanji)))) | |
90 | 104 | ((? reading? r) | |
91 | - | (update-result result #:readings (cons r (result-readings result)))) | |
105 | + | (update-result result #:readings | |
106 | + | (append (result-readings result) (list r)))) | |
92 | 107 | ((? meaning? s) | |
93 | - | (update-result result #:meanings (cons s (result-meanings result)))) | |
108 | + | (update-result result #:meanings | |
109 | + | (append (result-meanings result) (list s)))) | |
94 | 110 | ((? string? _) result)) | |
95 | 111 | (cdr lst)))))) | |
96 | 112 | (let* ((word (if (null? (result-kanjis result)) |
modules/nani/result/wadoku.scm
67 | 67 | ((? meaning? s) | |
68 | 68 | (merge-meanings s meaning)) | |
69 | 69 | ((? source? s) | |
70 | - | (update-meaning meaning #:sources (cons s (meaning-sources meaning)))) | |
70 | + | (update-meaning meaning #:sources | |
71 | + | (append (meaning-sources meaning) (list s)))) | |
71 | 72 | (('ref (? string? r)) | |
72 | - | (update-meaning meaning #:references (cons r (meaning-references meaning)))) | |
73 | + | (update-meaning meaning #:references | |
74 | + | (append (meaning-references meaning) (list r)))) | |
73 | 75 | (('info (? string? r)) | |
74 | - | (update-meaning meaning #:infos (cons r (meaning-infos meaning)))) | |
76 | + | (update-meaning meaning #:infos | |
77 | + | (append (meaning-infos meaning) (list r)))) | |
75 | 78 | (('infos (? string? r)) | |
76 | - | (update-meaning meaning #:infos (cons r (meaning-infos meaning)))) | |
79 | + | (update-meaning meaning #:infos | |
80 | + | (append (meaning-infos meaning) (list r)))) | |
77 | 81 | (('infos (? list? r)) | |
78 | 82 | (update-meaning meaning #:infos (append r (meaning-infos meaning)))) | |
79 | 83 | (('trans (? string? r)) | |
80 | - | (update-meaning meaning #:glosses (cons (string-downcase r) | |
81 | - | (meaning-glosses meaning)))) | |
84 | + | (update-meaning meaning #:glosses | |
85 | + | (append (meaning-glosses meaning) (list r)))) | |
82 | 86 | (('related . _) meaning) | |
83 | 87 | (('transcr . _) meaning) | |
84 | 88 | (('pitch . _) meaning) | |
… | |||
117 | 121 | (('foreign foreign) | |
118 | 122 | (update-source source | |
119 | 123 | #:content (if (list? foreign) | |
120 | - | (append foreign (source-content source)) | |
121 | - | (cons foreign (source-content source))))) | |
124 | + | (append (source-content source) foreign) | |
125 | + | (append (source-content source) (list foreign))))) | |
122 | 126 | ((? list? l) (loop source l)) | |
123 | 127 | (_ source)) | |
124 | 128 | (cdr lst))))) | |
… | |||
130 | 134 | (loop | |
131 | 135 | (match (car lst) | |
132 | 136 | (('reading r) | |
133 | - | (update-reading reading #:readings (cons r (reading-readings reading)))) | |
137 | + | (update-reading reading #:readings | |
138 | + | (append (reading-readings reading) (list r)))) | |
134 | 139 | (_ reading)) | |
135 | 140 | (cdr lst))))) | |
136 | 141 | ||
… | |||
142 | 147 | (match (car lst) | |
143 | 148 | (('kanji kanji) | |
144 | 149 | (loop | |
145 | - | (update-result result #:kanjis (cons kanji (result-kanjis result))) | |
150 | + | (update-result result #:kanjis | |
151 | + | (append (result-kanjis result) (list kanji))) | |
146 | 152 | last-source (cdr lst))) | |
147 | 153 | ((? reading? reading) | |
148 | 154 | (loop | |
149 | - | (update-result result #:readings (cons reading (result-readings result))) | |
155 | + | (update-result result #:readings | |
156 | + | (append (result-readings result) (list reading))) | |
150 | 157 | last-source (cdr lst))) | |
151 | 158 | ((? meaning? meaning) | |
152 | 159 | (loop | |
153 | 160 | (update-result result | |
154 | 161 | #:meanings | |
155 | - | (cons | |
156 | - | (if last-source | |
157 | - | (update-meaning meaning | |
158 | - | #:sources (cons last-source (meaning-sources meaning))) | |
159 | - | meaning) | |
160 | - | (result-meanings result))) | |
162 | + | (append | |
163 | + | (result-meanings result) | |
164 | + | (list | |
165 | + | (if last-source | |
166 | + | (update-meaning meaning | |
167 | + | #:sources | |
168 | + | (append (meaning-sources meaning) (list last-source))) | |
169 | + | meaning)))) | |
161 | 170 | last-source (cdr lst))) | |
162 | 171 | ((? list? l) | |
163 | 172 | (loop (loop result last-source l) last-source (cdr lst))) | |
… | |||
332 | 341 | ;(loop (cons `(info ,genki) infos) result lst)) | |
333 | 342 | (loop infos result lst)) | |
334 | 343 | ((('jlpt . jlpt) lst ...) | |
335 | - | (loop (cons `(info ,(string-append "jlpt-" jlpt)) infos) result lst)) | |
344 | + | (loop (append infos `((info ,(string-append "jlpt-" jlpt)))) result lst)) | |
336 | 345 | ((('ref . (? string? ref)) lst ...) | |
337 | - | (loop (cons `(ref ,ref) infos) result lst)) | |
346 | + | (loop (append infos `((ref ,ref))) result lst)) | |
338 | 347 | ((('ref (? string? ref)) lst ...) | |
339 | - | (loop (cons `(ref ,ref) infos) result lst)) | |
348 | + | (loop (append infos `((ref ,ref))) result lst)) | |
340 | 349 | ((('jap l) lst ...) | |
341 | 350 | (sub-loop loop infos result lst l)) | |
342 | 351 | ((('foreign l) lst ...) |