(char-db-json-insert-char-features): Add "@type" based on glyph
authorMORIOKA Tomohiko <tomo.git@chise.org>
Fri, 6 May 2016 00:18:24 +0000 (09:18 +0900)
committerMORIOKA Tomohiko <tomo.git@chise.org>
Fri, 6 May 2016 00:18:24 +0000 (09:18 +0900)
granularity.

char-db-json.el

index a8b897e..d8044d1 100644 (file)
   (unless column
     (setq column (current-column)))
   (let ((est-view-url-prefix "http://chise.org/est/view")
+       id obj-id type
        name value ; has-long-ccs-name
        rest
        radical strokes
      (format "{ \"@context\": \"%s/genre/character/context.json\""
             est-view-url-prefix))
     (setq line-separator (format ",%s" line-breaking))
-    (insert (format "%s \"@id\": \"%s\""
-                   line-separator
-                   (www-uri-make-object-url char)))
+    (setq id (www-uri-make-object-url char))
+    (insert (format "%s \"@id\": \"%s\"" line-separator id))
+    (setq obj-id (file-name-nondirectory id))
+    (setq type
+         (cond
+          ((string-match "^a2\\." obj-id)
+           "chise:super-abstract-character")
+          ((string-match "^a\\." obj-id)
+           "chise:abstract-character")
+          ((string-match "^o\\." obj-id)
+           "chise:unified-glyph")
+          ((string-match "^rep\\." obj-id)
+           "chise:abstract-glyph")
+          ((string-match "^g\\." obj-id)
+           "chise:detailed-glyph")
+          ((string-match "^g2\\." obj-id)
+           "chise:abstract-glyph-form")
+          ((string-match "^gi\\." obj-id)
+           "chise:abstract-glyph-form")
+          ((string-match "^repi\\." obj-id)
+           "chise:glyph-image")
+          (t
+           "chise:character")
+          ))
+    (insert (format "%s \"@type\": \"%s\"" line-separator type))
     (when (memq '<-subsumptive attributes)
       (when (or readable (not for-sub-node))
        (when (setq value (get-char-attribute char '<-subsumptive))