Commit 999d4947 authored by MORIOKA Tomohiko's avatar MORIOKA Tomohiko
Browse files

(chise-json-dump-char): Modify the format of index_with-root.jsonld to

omit detailed information of root-character.
(chise-json-api-character-get-info): New implementation to generate
relative representation from the root node.
parent 3face816
......@@ -2621,16 +2621,14 @@
(setq file (expand-file-name "index_with-root.jsonld" dir))
(or force-rewrite
(not (file-exists-p file))))
(setq root-info (chise-json-char-get-info root-char))
(setq root-id (chise-json-char-get-id root-char))
(erase-buffer)
(insert
(json-encode
(list* '(@context . "http://api.chise.org/contexts/v1/chise.jsonld")
(cons '$target id)
root-info)))
(list '(@context . "http://api.chise.org/contexts/v1/chise.jsonld")
(cons '$target id)
(cons '@id root-id))))
(write-region (point-min)(point-max) file)
(setq root-char (chise-json-char-get-root root-char))
(setq root-id (chise-json-char-get-id root-char))
(setq path (chise-json-dump-get-path root-id))
(setq dir (expand-file-name path chise-json-dump-directory))
(unless (file-exists-p dir)
......@@ -2639,6 +2637,7 @@
(when (or force-rewrite
(not (file-exists-p file)))
(erase-buffer)
(setq root-info (chise-json-char-get-info root-char))
(insert
(json-encode
(list* '(@context . "http://api.chise.org/contexts/v1/chise.jsonld")
......@@ -2673,7 +2672,8 @@
(defun chise-json-api-character-get-info (args)
(let ((coding-system-for-read 'utf-8-mcs-er)
char id char-CCS-spec
root-char dest ret
root-char root-id
dest ret
path dir file)
(when (and (setq char (assoc "character" args))
(setq char (cdr char))
......@@ -2689,21 +2689,29 @@
(setq char (define-char (list ret)))
))
(setq char-CCS-spec (chise-json-char-get-CCS-spec char)))
(setq root-char (chise-json-char-get-root char))
(setq id (chise-json-make-char-id (caar char-CCS-spec)(cdar char-CCS-spec)))
(setq path (chise-json-dump-get-path id))
(setq root-id
(if (eq char root-char)
id
(chise-json-char-get-id root-char)))
(setq path (chise-json-dump-get-path root-id))
(setq dir (expand-file-name path chise-json-dump-directory))
(setq file (expand-file-name "index.jsonld" dir))
(cons
(if (or (file-exists-p
(setq file (expand-file-name "index_with-root.jsonld" dir)))
(file-exists-p
(setq file (expand-file-name "index.jsonld" dir))))
(if (file-exists-p file)
(with-temp-buffer
(insert-file-contents-literally file)
(when (not (eq char root-char))
(goto-char (point-min))
(when (search-forward "\"@id\":" nil t)
(goto-char (match-beginning 0))
(insert (format "\"$target\": \"%s\",\n "
id))))
(buffer-substring (point-min)(point-max))
;; (encode-coding-string (buffer-substring (point-min)(point-max))
;; 'utf-8-mcs-er)
)
(setq root-char (chise-json-char-get-root char))
(setq dest (chise-json-char-get-info root-char nil 'without-CCS-spec))
(unless (eq char root-char)
(setq dest (cons (cons '$target id)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment