X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=est-eval.el;h=7d5b55ac0526876c24831b97d5b1679eee93d392;hb=d00913fb8c672303d39b3fcb37ec5c023dffdf98;hp=5624e6a2cc133fb0e2b60b97f88a1359c0361d7c;hpb=901436ff657087553045d8ad3ccf52daea4c8c41;p=chise%2Fest.git diff --git a/est-eval.el b/est-eval.el index 5624e6a..7d5b55a 100644 --- a/est-eval.el +++ b/est-eval.el @@ -1,6 +1,8 @@ ;; -*- coding: utf-8-mcs-er -*- (require 'cwiki-common) +(defvar est-eval-list-feature-items-limit 20) + (defun ruimoku-format-volume (spec value year lang) (when (stringp spec) (setq spec (car (read-from-string spec)))) @@ -12,16 +14,16 @@ ((eq spec 02) (concat value "巻")) ((eq spec 03) (concat value "号")) ((eq spec 04) (concat value "編")) - ((eq spec 05) (concat value ">-33870;")) + ((eq spec 05) (concat value "&MJ019590;")) ((eq spec 06) (concat value "集")) ((eq spec 07) (concat value "輯")) - ((eq spec 08) (concat value ">-53119;")) - ((eq spec 09) (concat value ">-53119;分")) + ((eq spec 08) (concat value "部")) + ((eq spec 09) (concat value "部分")) ((eq spec 10) (concat value "冊")) ((eq spec 11) (concat value "分冊")) - ((eq spec 12) (concat value "&J90-3C21;")) - ((eq spec 13) (concat value ">-18140;号")) - ((eq spec 14) (concat value "特>-56392;号")) + ((eq spec 12) (concat value "次")) + ((eq spec 13) (concat value "月号")) + ((eq spec 14) (concat value "特集号")) ((eq spec 15) (concat value "本")) ((eq spec 16) (concat value "分")) ((eq spec 51) (concat "Vol." value)) @@ -62,6 +64,33 @@ value))) (est-eval-value-as-S-exp value))) +(defun est-eval-value-as-image-resource (value &optional accept-full-image) + (let ((name (concord-object-get value 'name))) + (cond + ((concord-object-get value 'image-offset-x) + (list 'img (list* :src (or (concord-object-get value '=location@iiif) + (concord-object-get value '=location)) + (if name + (list :alt name)))) + ) + (accept-full-image + (list 'img (list* :src (concord-object-get value '=location) + (if name + (list :alt name)))) + ) + (t + name)))) + +(defun est-eval-value-as-glyph-image (value) + (let ((image-resource (car (concord-object-get value '->image-resource)))) + (est-eval-value-as-image-resource image-resource))) + +(defun est-eval-value-as-image-object (value) + (let ((image-resource (car (concord-object-get value '->image-resource)))) + (list 'object (list :object value) + (est-eval-value-as-image-resource + image-resource 'accept-full-image)))) + ;; (defun est-journal-volume-object-get-volume-format (spec feature) ;; (when (integerp spec) ;; (setq spec (format "%02d" spec))) @@ -71,17 +100,17 @@ ;; ((string= spec "01") `((decimal (:feature ,feature)) "期")) ;; ((string= spec "02") `((decimal (:feature ,feature)) "巻")) ;; ((string= spec "03") `((decimal (:feature ,feature)) "号")) -;; ((string= spec "04") `((decimal (:feature ,feature)) ">-35694;")) -;; ((string= spec "05") `((decimal (:feature ,feature)) ">-33870;")) -;; ((string= spec "06") `((decimal (:feature ,feature)) ">-56392;")) +;; ((string= spec "04") `((decimal (:feature ,feature)) "&AJ1-03620;")) +;; ((string= spec "05") `((decimal (:feature ,feature)) "&MJ019590;")) +;; ((string= spec "06") `((decimal (:feature ,feature)) "集")) ;; ((string= spec "07") `((decimal (:feature ,feature)) "輯")) -;; ((string= spec "08") `((decimal (:feature ,feature)) ">-53119;")) -;; ((string= spec "09") `((decimal (:feature ,feature)) ">-53119;分")) +;; ((string= spec "08") `((decimal (:feature ,feature)) "部")) +;; ((string= spec "09") `((decimal (:feature ,feature)) "部分")) ;; ((string= spec "10") `((decimal (:feature ,feature)) "冊")) ;; ((string= spec "11") `((decimal (:feature ,feature)) "分冊")) -;; ((string= spec "12") `((decimal (:feature ,feature)) "&J90-3C21;")) -;; ((string= spec "13") `((decimal (:feature ,feature)) ">-18140;号")) -;; ((string= spec "14") `((decimal (:feature ,feature)) "特>-56392;号")) +;; ((string= spec "12") `((decimal (:feature ,feature)) "次")) +;; ((string= spec "13") `((decimal (:feature ,feature)) "月号")) +;; ((string= spec "14") `((decimal (:feature ,feature)) "特集号")) ;; ((string= spec "15") `((decimal (:feature ,feature)) "本")) ;; ((string= spec "16") `((decimal (:feature ,feature)) "分")) ;; ((string= spec "51") `("Vol." ((decimal (:feature ,feature))))) @@ -325,7 +354,13 @@ ;; ((eq genre 'creator@ruimoku) ;; (est-eval-creator value) ;; ) - (t + ((eq genre 'image-resource) + (est-eval-value-as-image-resource value) + ) + ((eq genre 'glyph-image) + (est-eval-value-as-glyph-image value) + ) + (t (setq genre-o (concord-decode-object '=id genre 'genre)) (or (and genre-o (setq format @@ -344,6 +379,30 @@ ))) (est-eval-value-default value))) +(defun est-eval-value-as-character (value) + (let (ret) + (if (and (concord-object-p value) + (setq ret (concord-object-get value 'character))) + (list 'object (list :object value) + (mapconcat #'char-to-string ret "")) + (est-eval-value-as-object value)))) + +(defun est-eval-value-as-location (value) + (let (ret) + (if (and (concord-object-p value) + (setq ret (concord-object-get value '=location))) + (list 'object (list :object value) + ret) + (est-eval-value-as-object value)))) + +(defun est-eval-value-as-name (value) + (let (ret) + (if (and (concord-object-p value) + (setq ret (concord-object-get value 'name))) + (list 'object (list :object value) + ret) + (est-eval-value-as-object value)))) + (defun est-eval-value-as-HEX (value) (if (integerp value) (list 'HEX nil (format "%X" value)) @@ -367,6 +426,44 @@ (format "%c" (ideographic-radical value))) (est-eval-value-as-S-exp value))) +(defun est-eval-value-as-shuowen-radical (value) + (if (and (integerp value) + (<= 0 value) + (<= value 540)) + (list 'shuowen-radical + nil + (format "%c" (shuowen-radical value))) + (est-eval-value-as-S-exp value))) + +(defun daijiten-page-number-to-ndl-950498 (page) + (+ (/ page 2) + (cond ((< page 229) + 23) + ((< page 261) + 24) + ((< page 263) + 25) + ((< page 516) ; 284=285 + 26) + (t + 27)))) + +(defun est-eval-value-as-daijiten-page (value) + (if (integerp value) + (list 'link + (list :ref + (format "http://image.chise.org/tify/?manifest=https://www.dl.ndl.go.jp/api/iiif/950498/manifest.json&tify={%%22pages%%22:[%d]}" + (daijiten-page-number-to-ndl-950498 value))) + value))) + +(defun est-eval-value-as-Web-yunzi-char (value) + (if (char-or-char-int-p value) + (list 'link + (list :ref + (format "http://suzukish.s252.xrea.com/search/inkyo/yunzi/%c" + value)) + (format "/%s/" (char-to-string value))))) + (defun est-eval-value-as-object-list (value &optional separator subtype) (if (and (listp value) (listp (cdr value))) @@ -381,6 +478,62 @@ (error (format "%s" value))) (format "%s" value))) +(defun est-eval-value-as-char-list (value &optional separator subtype) + (if (and (listp value) + (listp (cdr value))) + (condition-case nil + (let (props) + (if separator + (setq props (list :separator separator))) + (if subtype + (setq props (list* :subtype subtype props))) + (list* 'list props + (mapcar #'est-eval-value-as-character value))) + (error (format "%s" value))) + (format "%s" value))) + +(defun est-eval-value-as-location-list (value &optional separator subtype) + (if (and (listp value) + (listp (cdr value))) + (condition-case nil + (let (props) + (if separator + (setq props (list :separator separator))) + (if subtype + (setq props (list* :subtype subtype props))) + (list* 'list props + (mapcar #'est-eval-value-as-location value))) + (error (format "%s" value))) + (format "%s" value))) + +(defun est-eval-value-as-name-list (value &optional separator subtype) + (if (and (listp value) + (listp (cdr value))) + (condition-case nil + (let (props) + (if separator + (setq props (list :separator separator))) + (if subtype + (setq props (list* :subtype subtype props))) + (list* 'list props + (mapcar #'est-eval-value-as-name value))) + (error (format "%s" value))) + (format "%s" value))) + +(defun est-eval-value-as-image-list (value &optional separator subtype) + (if (and (listp value) + (listp (cdr value))) + (condition-case nil + (let (props) + (if separator + (setq props (list :separator separator))) + (if subtype + (setq props (list* :subtype subtype props))) + (list* 'image-list props + (mapcar #'est-eval-value-as-image-object value))) + (error (format "%s" value))) + (format "%s" value))) + (defun est-eval-value-as-composition-list (value &optional separator subtype) (if (and (listp value) (listp (cdr value))) @@ -424,10 +577,18 @@ (error (format "%s" value))) (format "%s" value))) +;; (defun est-eval-value-as-ids (value) +;; (if (listp value) +;; (list 'ids nil (ideographic-structure-to-ids value)) +;; (format "%s" value))) (defun est-eval-value-as-ids (value) (if (listp value) - (list 'ids nil (ideographic-structure-to-ids value)) - (format "%s" value))) + (list* 'ids + nil + (mapcar #'est-eval-value-as-object + (ideographic-structure-to-ids value)) + ) + (est-eval-value-default value))) (defun est-eval-value-as-space-separated-ids (value) (if (listp value) @@ -469,7 +630,7 @@ '=id item 'article@ruimoku) (intern unit))))) ) - ((eq source 'zob1968) + ((memq source '(zob1959 zob1968)) (if (and (symbolp item) (setq num (symbol-name item)) (string-match @@ -523,7 +684,8 @@ (list (est-eval-value-as-object (intern unit)))) )) (list* 'res-link - (list :source source :item item) + (list :separator " " + :source source :item item) source-objs) ) (t @@ -532,6 +694,34 @@ value))) (est-eval-value-default value))) +(defun est-eval-value-as-daijiten-page-list (value &optional separator subtype) + (if (and (listp value) + (listp (cdr value))) + (condition-case nil + (let (props) + (if separator + (setq props (list :separator separator))) + (if subtype + (setq props (list* :subtype subtype props))) + (list* 'list props + (mapcar #'est-eval-value-as-daijiten-page value))) + (error (format "%s" value))) + (format "%s" value))) + +(defun est-eval-value-as-Web-yunzi-char-list (value &optional separator subtype) + (if (and (listp value) + (listp (cdr value))) + (condition-case nil + (let (props) + (if separator + (setq props (list :separator separator))) + (if subtype + (setq props (list* :subtype subtype props))) + (list* 'list props + (mapcar #'est-eval-value-as-Web-yunzi-char value))) + (error (format "%s" value))) + (format "%s" value))) + (defun est-eval-value-as-creators-names (value &optional subtype) (if (listp value) (let (role-name) @@ -568,9 +758,11 @@ '(:subtype unordered-list) '(:separator " ")) (mapcar (lambda (creator) - (est-eval-list - '((value (:feature <-creator))) - creator nil)) + (if (concord-object-p creator) + (est-eval-list + '((value (:feature <-creator))) + creator nil) + (est-eval-value-default creator))) value)) (est-eval-value-default value))) @@ -648,6 +840,10 @@ ((eq format 'wiki-text) (est-eval-list value object feature-name nil uri-object) ) + ((eq format 'unordered-link-list) + (est-eval-list value object feature-name nil uri-object + '(:subtype unordered-list :separator " ")) + ) ((eq format 'S-exp) (est-eval-value-as-S-exp value) ) @@ -655,6 +851,8 @@ (est-eval-value-as-kuten value)) ((eq format 'kangxi-radical) (est-eval-value-as-kangxi-radical value)) + ((eq format 'shuowen-radical) + (est-eval-value-as-shuowen-radical value)) ((eq format 'ids) (est-eval-value-as-ids value)) ((eq format 'decomposition) @@ -664,6 +862,14 @@ ((or (eq format 'space-separated) (eq format 'space-separated-char-list)) (est-eval-value-as-object-list value " ")) + ((eq format 'char-list) + (est-eval-value-as-char-list value nil)) + ((eq format 'location-list) + (est-eval-value-as-location-list value nil)) + ((eq format 'name-list) + (est-eval-value-as-name-list value nil)) + ((eq format 'image-list) + (est-eval-value-as-image-list value nil)) ((eq format 'unordered-list) (est-eval-value-as-object-list value nil 'unordered-list)) ((eq format 'unordered-composition-list) @@ -682,6 +888,10 @@ (est-eval-value-as-created-works value 'unordered-list)) ((eq format 'journal-volume-list) (est-eval-value-as-journal-volumes value)) + ((eq format 'space-separated-daijiten-page-list) + (est-eval-value-as-daijiten-page-list value " ")) + ((eq format 'space-separated-Web-yunzi-char-list) + (est-eval-value-as-Web-yunzi-char-list value " ")) (t (est-eval-value-default value) )) @@ -693,9 +903,11 @@ (setq value (www-get-feature-value object feature-name))) (unless format (setq format (www-feature-value-format feature-name))) - (if (consp value) + (if (and (consp value) + est-eval-list-feature-items-limit + (not (eq feature-name 'sources))) (let ((ret (condition-case nil - (nthcdr 255 value) + (nthcdr est-eval-list-feature-items-limit value) (error nil nil)))) (when ret (setcdr ret @@ -735,7 +947,8 @@ ((null exp) "") ((consp exp) (cond - ((memq (car exp) '(value decimal hex HEX ku-ten kangxi-radical + ((memq (car exp) '(value decimal hex HEX ku-ten + kangxi-radical shuowen-radical S-exp string default)) (let ((fn (plist-get (nth 1 exp) :feature)) domain domain-fn ret) @@ -823,7 +1036,7 @@ exp))))) (defun est-eval-list (format-list object feature-name - &optional lang uri-object) + &optional lang uri-object list-props) (if (consp format-list) (let ((ret (mapcar @@ -831,7 +1044,7 @@ (est-eval-unit exp object feature-name lang uri-object nil)) format-list))) (if (cdr ret) - (list* 'list nil ret) + (list* 'list list-props ret) (car ret))) (est-eval-unit format-list object feature-name lang uri-object nil)))