Fix jmdict generation

Julien LepillerThu Jun 04 00:08:23+0200 2020

0fb518d

Fix jmdict generation

modules/nani/jmdict/xml.scm

6969
          ((? source? s) (update-sense sense #:sources (cons s (sense-sources sense))))
7070
          (('tag (? integer? r)) (update-sense sense #:tags (cons r (sense-tags sense))))
7171
          (('gloss (? string? r)) (update-sense sense #:glosses (cons r (sense-glosses sense))))
72-
          (('lang (? string? l)) (update-sense sense #:language l))
72+
          ((('xml . 'lang) (? string? l)) (update-sense sense #:language l))
7373
          (((? symbol? s) v) (throw 'unknown-content s v))
7474
          ((? list? l) (loop sense l))
7575
          ((? string? _) sense))

9595
                   (car (result-kanjis result))))
9696
           (entity (frequency-entity frq word))
9797
           (sense1 (car (result-senses result)))
98-
           (sense1 (update-sense sense1 #:tags (cons entity (sense-tags sense1))))
98+
           (sense1 (if entity
99+
                       (update-sense sense1
100+
                         #:tags (cons (get-tag entity) (sense-tags sense1)))
101+
                       sense1))
99102
           (senses (cons sense1 (cdr (result-senses result)))))
100103
      (update-result result
101104
        #:points (get-points (update-result result #:senses senses))

117120
    ('keb (if (and (= (length lst) 1) (string? (car lst)))
118121
              `(kanji ,(car lst))
119122
              (throw 'invalid-keb lst)))
120-
    ('s_inf (if (and (= (length lst) 1) (string? (car lst)))
121-
                `(info ,(car lst))
123+
    ('s_inf (if (null? (filter (lambda (s) (not (string? s))) lst))
124+
                `(info ,(apply string-append lst))
122125
                (throw 'invalid-s_inf lst)))
123126
    ('dial (if (and (= (length lst) 1) (string? (car lst)))
124127
               `(tag ,(get-tag (car lst)))

138141
    ('ant (if (and (= (length lst) 1) (string? (car lst)))
139142
              `(ref ,(car lst))
140143
              (throw 'invalid-ant lst)))
141-
    ('reb `(reading ,lst))
144+
    ('reb (if (and (= (length lst) 1) (string? (car lst)))
145+
              `(reading ,(car lst))
146+
              (throw 'invalid-reb lst)))
142147
    ('r_ele (sxml->reading lst))
143148
    ('k_ele (car (filter list? lst)))
144149
    ('pos (if (and (= (length lst) 1) (string? (car lst)))

147152
    ('xref (if (and (= (length lst) 1) (string? (car lst)))
148153
               `(ref ,(car lst))
149154
               (throw 'invalid-xref lst)))
150-
    ('gloss (append
151-
              (filter list? lst)
152-
              (map (lambda (v) `(gloss ,v)) (filter string? lst))))
155+
    ('gloss (cons
156+
              `(gloss ,(apply string-append (filter string? lst)))
157+
              (filter list? lst)))
153158
    ('lsource (sxml->source lst))
154159
    ('sense (sxml->sense lst))
155160
    ('entry (sxml->result lst frq))))